Skip to content

Commit

Permalink
ci(docker): using docker build args instead of extra dockerfile for f…
Browse files Browse the repository at this point in the history
…fmpeg (AlistGo#6989)

* build: using docker build arg to determine install ffmpeg or not

* ci: pass build-args to ffmpeg image build step
  • Loading branch information
Mmx233 authored and Three-taile-dragon committed Sep 26, 2024
1 parent d802af1 commit b816a52
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,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:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,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:
Expand Down
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@ COPY ./ ./
RUN bash build.sh release docker

FROM alpine:edge

ARG INSTALL_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 && \
[ "$INSTALL_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" ]
18 changes: 12 additions & 6 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
FROM alpine:edge

ARG TARGETPLATFORM
ARG INSTALL_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
[ "$INSTALL_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" ]
4 changes: 0 additions & 4 deletions Dockerfile.ffmpeg

This file was deleted.

0 comments on commit b816a52

Please sign in to comment.