From 1dac5204724c0b24666fbce532f2d952ec4e4056 Mon Sep 17 00:00:00 2001 From: Mmx Date: Sun, 11 Aug 2024 20:12:40 +0800 Subject: [PATCH 1/2] build: using docker build arg to determine install ffmpeg or not --- Dockerfile | 15 +++++++++++---- Dockerfile.ci | 18 ++++++++++++------ Dockerfile.ffmpeg | 4 ---- 3 files changed, 23 insertions(+), 14 deletions(-) delete mode 100644 Dockerfile.ffmpeg diff --git a/Dockerfile b/Dockerfile index 23ca42da201..e906db514eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,16 +8,23 @@ COPY ./ ./ RUN bash build.sh release docker FROM alpine:edge + +ARG FFMPEG=false LABEL MAINTAINER="i@nn.ci" -VOLUME /opt/alist/data/ + WORKDIR /opt/alist/ -COPY --from=builder /app/bin/alist ./ -COPY entrypoint.sh /entrypoint.sh + RUN apk update && \ apk upgrade --no-cache && \ apk add --no-cache bash ca-certificates su-exec tzdata; \ - chmod +x /entrypoint.sh && \ + [ "$FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \ rm -rf /var/cache/apk/* + +COPY --from=builder /app/bin/alist ./ +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh && /entrypoint.sh version + ENV PUID=0 PGID=0 UMASK=022 +VOLUME /opt/alist/data/ EXPOSE 5244 5245 CMD [ "/entrypoint.sh" ] \ No newline at end of file diff --git a/Dockerfile.ci b/Dockerfile.ci index c25e2471b16..68df7b9b282 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -1,16 +1,22 @@ FROM alpine:edge + ARG TARGETPLATFORM +ARG FFMPEG=false LABEL MAINTAINER="i@nn.ci" -VOLUME /opt/alist/data/ + WORKDIR /opt/alist/ -COPY /build/${TARGETPLATFORM}/alist ./ -COPY entrypoint.sh /entrypoint.sh + RUN apk update && \ apk upgrade --no-cache && \ apk add --no-cache bash ca-certificates su-exec tzdata; \ - chmod +x /entrypoint.sh && \ - rm -rf /var/cache/apk/* && \ - /entrypoint.sh version + [ "$FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \ + rm -rf /var/cache/apk/* + +COPY /build/${TARGETPLATFORM}/alist ./ +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh && /entrypoint.sh version + ENV PUID=0 PGID=0 UMASK=022 +VOLUME /opt/alist/data/ EXPOSE 5244 5245 CMD [ "/entrypoint.sh" ] \ No newline at end of file diff --git a/Dockerfile.ffmpeg b/Dockerfile.ffmpeg deleted file mode 100644 index 9799d777edf..00000000000 --- a/Dockerfile.ffmpeg +++ /dev/null @@ -1,4 +0,0 @@ -FROM xhofe/alist:latest -RUN apk update && \ - apk add --no-cache ffmpeg \ - rm -rf /var/cache/apk/* \ No newline at end of file From f453522fcaee1b4a0bb45e152c659cfa05638d3d Mon Sep 17 00:00:00 2001 From: Mmx Date: Sun, 11 Aug 2024 20:15:44 +0800 Subject: [PATCH 2/2] ci: pass build-args to ffmpeg image build step --- .github/workflows/build_docker.yml | 7 ++----- .github/workflows/release_docker.yml | 3 ++- Dockerfile | 4 ++-- Dockerfile.ci | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index c6c301f3ba8..cfd045117e1 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -74,19 +74,16 @@ jobs: labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x - - name: Replace dockerfile tag - run: | - sed -i -e "s/latest/main/g" Dockerfile.ffmpeg - - name: Build and push with ffmpeg id: docker_build_ffmpeg uses: docker/build-push-action@v6 with: context: . - file: Dockerfile.ffmpeg + file: Dockerfile.ci push: ${{ github.event_name == 'push' }} tags: ${{ steps.meta-ffmpeg.outputs.tags }} labels: ${{ steps.meta-ffmpeg.outputs.labels }} + build-args: INSTALL_FFMPEG=true platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x build_docker_with_aria2: diff --git a/.github/workflows/release_docker.yml b/.github/workflows/release_docker.yml index 3078d0c3094..4e039ba0780 100644 --- a/.github/workflows/release_docker.yml +++ b/.github/workflows/release_docker.yml @@ -74,10 +74,11 @@ jobs: uses: docker/build-push-action@v6 with: context: . - file: Dockerfile.ffmpeg + file: Dockerfile.ci push: true tags: ${{ steps.meta-ffmpeg.outputs.tags }} labels: ${{ steps.meta-ffmpeg.outputs.labels }} + build-args: INSTALL_FFMPEG=true platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x release_docker_with_aria2: diff --git a/Dockerfile b/Dockerfile index e906db514eb..74fa2165482 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ RUN bash build.sh release docker FROM alpine:edge -ARG FFMPEG=false +ARG INSTALL_FFMPEG=false LABEL MAINTAINER="i@nn.ci" WORKDIR /opt/alist/ @@ -17,7 +17,7 @@ WORKDIR /opt/alist/ RUN apk update && \ apk upgrade --no-cache && \ apk add --no-cache bash ca-certificates su-exec tzdata; \ - [ "$FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \ + [ "$INSTALL_FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \ rm -rf /var/cache/apk/* COPY --from=builder /app/bin/alist ./ diff --git a/Dockerfile.ci b/Dockerfile.ci index 68df7b9b282..3f437f16dfe 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -1,7 +1,7 @@ FROM alpine:edge ARG TARGETPLATFORM -ARG FFMPEG=false +ARG INSTALL_FFMPEG=false LABEL MAINTAINER="i@nn.ci" WORKDIR /opt/alist/ @@ -9,7 +9,7 @@ WORKDIR /opt/alist/ RUN apk update && \ apk upgrade --no-cache && \ apk add --no-cache bash ca-certificates su-exec tzdata; \ - [ "$FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \ + [ "$INSTALL_FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \ rm -rf /var/cache/apk/* COPY /build/${TARGETPLATFORM}/alist ./