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:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name != 'pull_request'
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [linux/amd64, linux/arm64, linux/arm/v7]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
@ -37,8 +34,6 @@ jobs:
|
||||
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
||||
push: true
|
||||
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
|
||||
uses: docker/build-push-action@v4
|
||||
@ -48,5 +43,4 @@ jobs:
|
||||
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
||||
push: true
|
||||
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
|
||||
|
||||
|
67
.github/workflows/ci.yml
vendored
67
.github/workflows/ci.yml
vendored
@ -10,9 +10,6 @@ jobs:
|
||||
build-test-publish:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name != 'pull_request'
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [linux/amd64, linux/arm64, linux/arm/v7]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@ -28,54 +25,64 @@ jobs:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Set tags name
|
||||
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
|
||||
- name: Build Docker image (linux/amd64)
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: ${{ matrix.platform }}
|
||||
platforms: linux/amd64
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: false
|
||||
load: true
|
||||
tags: ${{ env.TAGNAME }}
|
||||
tags: ${{ env.TEST_TAG }}-linux-amd64
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
||||
|
||||
- name: Test Docker image
|
||||
run: docker run --rm ${{ env.TAGNAME }} -h
|
||||
- name: Build Docker image (linux/arm64)
|
||||
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
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
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
|
||||
|
||||
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
|
||||
uses: peter-evans/dockerhub-description@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
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
|
||||
# run unless event type is pull_request
|
||||
if: github.event_name != 'pull_request'
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [linux/amd64, linux/arm64, linux/arm/v7]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up QEMU
|
||||
@ -58,8 +55,6 @@ jobs:
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
platforms: ${{ matrix.platform }}
|
||||
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
||||
push: true
|
||||
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
|
||||
|
||||
FROM hanxi/xiaomusic:runtime
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/.venv /app/.venv
|
||||
COPY xiaomusic/ ./xiaomusic/
|
||||
COPY plugins/ ./plugins/
|
||||
COPY xiaomusic.py .
|
||||
COPY --from=builder /app/xiaomusic/ ./xiaomusic/
|
||||
COPY --from=builder /app/plugins/ ./plugins/
|
||||
COPY --from=builder /app/xiaomusic.py .
|
||||
ENV XIAOMUSIC_HOSTNAME=192.168.2.5
|
||||
ENV XIAOMUSIC_PORT=8090
|
||||
VOLUME /app/conf
|
||||
|
Loading…
Reference in New Issue
Block a user