build: 镜像编译优化
This commit is contained in:
parent
6d7ff48913
commit
e65c2ca3c9
8
.github/workflows/build-base-image.yml
vendored
8
.github/workflows/build-base-image.yml
vendored
@ -14,9 +14,6 @@ jobs:
|
|||||||
build-image:
|
build-image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
platform: [linux/amd64, linux/arm64, linux/arm/v7]
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
@ -37,8 +34,6 @@ jobs:
|
|||||||
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:runtime
|
tags: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:runtime
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
|
||||||
|
|
||||||
- name: Build and push builder
|
- name: Build and push builder
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
@ -48,5 +43,4 @@ jobs:
|
|||||||
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:builder
|
tags: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:builder
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
|
||||||
|
71
.github/workflows/ci.yml
vendored
71
.github/workflows/ci.yml
vendored
@ -10,12 +10,9 @@ jobs:
|
|||||||
build-test-publish:
|
build-test-publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
platform: [linux/amd64, linux/arm64, linux/arm/v7]
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
@ -28,54 +25,64 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Set tags name
|
- name: Build Docker image (linux/amd64)
|
||||||
id: gen_tag_name
|
|
||||||
env:
|
|
||||||
IMAGE_NAME: ${{ env.TEST_TAG }}
|
|
||||||
PLATFORM_NAME: ${{ matrix.platform }}
|
|
||||||
run: |
|
|
||||||
echo "TAGNAME=${IMAGE_NAME}-${PLATFORM_NAME//\//-}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Build Docker image
|
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
platforms: ${{ matrix.platform }}
|
platforms: linux/amd64
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
|
||||||
push: false
|
push: false
|
||||||
load: true
|
load: true
|
||||||
tags: ${{ env.TAGNAME }}
|
tags: ${{ env.TEST_TAG }}-linux-amd64
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
||||||
|
|
||||||
- name: Test Docker image
|
- name: Build Docker image (linux/arm64)
|
||||||
run: docker run --rm ${{ env.TAGNAME }} -h
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
platforms: linux/arm64
|
||||||
|
context: .
|
||||||
|
push: false
|
||||||
|
load: true
|
||||||
|
tags: ${{ env.TEST_TAG }}-linux-arm64
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
||||||
|
|
||||||
|
- name: Build Docker image (linux/arm/v7)
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
platforms: linux/arm/v7
|
||||||
|
context: .
|
||||||
|
push: false
|
||||||
|
load: true
|
||||||
|
tags: ${{ env.TEST_TAG }}-linux-arm-v7
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
||||||
|
|
||||||
|
# We test all the images on amd64 host here. This uses QEMU to emulate
|
||||||
|
# the other platforms.
|
||||||
|
- run: docker run --rm ${TEST_TAG}-linux-amd64 -h
|
||||||
|
- run: docker run --rm ${TEST_TAG}-linux-arm64 -h
|
||||||
|
- run: docker run --rm ${TEST_TAG}-linux-arm-v7 -h
|
||||||
|
|
||||||
|
# This will only push the previously built images.
|
||||||
- name: Publish to Docker Hub
|
- name: Publish to Docker Hub
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ env.TEST_TAG }}
|
tags: ${{ env.TEST_TAG }}
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
cache-from: type=local,src=/tmp/.buildx-cache-new
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
||||||
|
|
||||||
publish-readme:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build-test-publish
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Docker Hub Description
|
- name: Docker Hub Description
|
||||||
uses: peter-evans/dockerhub-description@v4
|
uses: peter-evans/dockerhub-description@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
repository: hanxi/xiaomusic
|
repository: hanxi/xiaomusic
|
||||||
|
|
||||||
|
- name: Move cache to limit growth
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/.buildx-cache
|
||||||
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
7
.github/workflows/release.yml
vendored
7
.github/workflows/release.yml
vendored
@ -40,9 +40,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# run unless event type is pull_request
|
# run unless event type is pull_request
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
platform: [linux/amd64, linux/arm64, linux/arm/v7]
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
@ -58,8 +55,6 @@ jobs:
|
|||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: ${{ matrix.platform }}
|
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:latest, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:stable
|
tags: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:latest, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:stable
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
|
||||||
|
@ -10,12 +10,11 @@ COPY xiaomusic.py .
|
|||||||
RUN pdm install --prod --no-editable
|
RUN pdm install --prod --no-editable
|
||||||
|
|
||||||
FROM hanxi/xiaomusic:runtime
|
FROM hanxi/xiaomusic:runtime
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=builder /app/.venv /app/.venv
|
COPY --from=builder /app/.venv /app/.venv
|
||||||
COPY xiaomusic/ ./xiaomusic/
|
COPY --from=builder /app/xiaomusic/ ./xiaomusic/
|
||||||
COPY plugins/ ./plugins/
|
COPY --from=builder /app/plugins/ ./plugins/
|
||||||
COPY xiaomusic.py .
|
COPY --from=builder /app/xiaomusic.py .
|
||||||
ENV XIAOMUSIC_HOSTNAME=192.168.2.5
|
ENV XIAOMUSIC_HOSTNAME=192.168.2.5
|
||||||
ENV XIAOMUSIC_PORT=8090
|
ENV XIAOMUSIC_PORT=8090
|
||||||
VOLUME /app/conf
|
VOLUME /app/conf
|
||||||
|
Loading…
Reference in New Issue
Block a user