From 8629c16fe41bdb406e935a39fe440e4071d78974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Wed, 30 Oct 2024 09:50:22 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E7=BC=96=E8=AF=91=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/{base.yml => build-base-image.yml} | 14 +++++++++++--- Dockerfile | 4 ++-- Dockerfile.builder | 11 +++++++++++ Dockerfile.base => Dockerfile.runtime | 1 + 4 files changed, 25 insertions(+), 5 deletions(-) rename .github/workflows/{base.yml => build-base-image.yml} (64%) create mode 100644 Dockerfile.builder rename Dockerfile.base => Dockerfile.runtime (94%) diff --git a/.github/workflows/base.yml b/.github/workflows/build-base-image.yml similarity index 64% rename from .github/workflows/base.yml rename to .github/workflows/build-base-image.yml index de2cf57..3f2fe67 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/build-base-image.yml @@ -18,11 +18,19 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push + - name: Build and push runtime uses: docker/build-push-action@v4 with: context: . - file: ./Dockerfile.base + file: ./Dockerfile.runtime platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:base + tags: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:runtime + - name: Build and push builder + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile.builder + platforms: linux/amd64,linux/arm64,linux/arm/v7 + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:builder diff --git a/Dockerfile b/Dockerfile index d5a7d44..01978bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10 AS builder +FROM hanxi/xiaomusic:builder AS builder ENV DEBIAN_FRONTEND=noninteractive RUN pip install -U pdm ENV PDM_CHECK_UPDATE=false @@ -9,7 +9,7 @@ COPY plugins/ ./plugins/ COPY xiaomusic.py . RUN pdm install --prod --no-editable -FROM hanxi/xiaomusic:base +FROM hanxi/xiaomusic:runtime WORKDIR /app COPY --from=builder /app/.venv /app/.venv diff --git a/Dockerfile.builder b/Dockerfile.builder new file mode 100644 index 0000000..82c0b7b --- /dev/null +++ b/Dockerfile.builder @@ -0,0 +1,11 @@ +FROM python:3.10 +ENV DEBIAN_FRONTEND=noninteractive +RUN pip install -U pdm +ENV PDM_CHECK_UPDATE=false +WORKDIR /app +COPY pyproject.toml README.md . +COPY xiaomusic/ ./xiaomusic/ +COPY plugins/ ./plugins/ +COPY xiaomusic.py . +RUN pdm install --prod --no-editable + diff --git a/Dockerfile.base b/Dockerfile.runtime similarity index 94% rename from Dockerfile.base rename to Dockerfile.runtime index 0574c1f..0a2779f 100644 --- a/Dockerfile.base +++ b/Dockerfile.runtime @@ -3,6 +3,7 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y \ wget \ + xz-utils \ libtiff6 \ libopenjp2-7 \ libxcb1 \