Skip to content

Commit

Permalink
Merge branch 'feat/docker_image_aio'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/release_docker.yml
  • Loading branch information
Mmx233 committed Dec 30, 2024
2 parents cbb9c45 + 09bbd89 commit 5a2d25c
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 31 deletions.
85 changes: 56 additions & 29 deletions .github/workflows/release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ on:
tags:
- 'v*'

env:
IMAGE_REGISTRY: 'mmx233/alist'
REGISTRY_USERNAME: 'mmx233'
REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
ARTIFACT_NAME: 'binaries_docker_release'
RELEASE_PLATFORMS: 'linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x,linux/ppc64le,linux/riscv64'

jobs:
release_docker:
name: Release Docker
build_binary:
name: Build Binaries for Docker Release
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -31,11 +38,42 @@ jobs:
- name: Build go binary
run: bash build.sh release docker-multiplatform

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: |
build/
!build/*.tgz
!build/musl-libs/**
release_docker:
needs: build_binary
name: Release Docker image
runs-on: ubuntu-latest
strategy:
matrix:
image: ["latest", "ffmpeg", "aria2", "aio"]
include:
- image: "latest"
build_arg: ""
tag_favor: ""
- image: "ffmpeg"
build_arg: "INSTALL_FFMPEG=true"
tag_favor: "suffix=-ffmpeg,onlatest=true"
- image: "aria2"
build_arg: "INSTALL_ARIA2=true"
tag_favor: "suffix=-aria2,onlatest=true"
- image: "aio"
build_arg: "INSTALL_FFMPEG=true,INSTALL_ARIA2=true"
tag_favor: "suffix=-aio,onlatest=true"
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
images: mmx233/alist
name: ${{ env.ARTIFACT_NAME }}
path: 'build/'

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -46,37 +84,26 @@ jobs:
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: mmx233
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.ci
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x,linux/ppc64le,linux/riscv64
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ env.REGISTRY_PASSWORD }}

- name: Docker meta with ffmpeg
id: meta-ffmpeg
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: mmx233/alist
images: ${{ env.IMAGE_REGISTRY }}
flavor: |
latest=true
suffix=-ffmpeg,onlatest=true
${{ matrix.tag_favor }}
- name: Build and push with ffmpeg
id: docker_build_ffmpeg
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
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,linux/ppc64le,linux/riscv64
build-args: ${{ matrix.build_arg }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ env.RELEASE_PLATFORMS }}
10 changes: 9 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN bash build.sh release docker
FROM alpine:edge

ARG INSTALL_FFMPEG=false
ARG INSTALL_ARIA2=false
LABEL MAINTAINER="[email protected]"

WORKDIR /opt/alist/
Expand All @@ -18,13 +19,20 @@ RUN apk update && \
apk upgrade --no-cache && \
apk add --no-cache bash ca-certificates su-exec tzdata; \
[ "$INSTALL_FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \
[ "$INSTALL_ARIA2" = "true" ] && apk add --no-cache curl aria2 && \
mkdir -p /root/.aria2 && \
wget https://github.com/P3TERX/aria2.conf/archive/refs/heads/master.tar.gz -O /tmp/aria-conf.tar.gz && \
tar -zxvf /tmp/aria-conf.tar.gz -C /root/.aria2 && rm -f /tmp/aria-conf.tar.gz && \
sed -i 's|rpc-secret|#rpc-secret|g' /root/.aria2/aria2.conf && \
touch /root/.aria2/aria2.session && \
/root/.aria2/tracker.sh ; \
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
ENV PUID=0 PGID=0 UMASK=022 RUN_ARIA2=${INSTALL_ARIA2}
VOLUME /opt/alist/data/
EXPOSE 5244 5245
CMD [ "/entrypoint.sh" ]
10 changes: 9 additions & 1 deletion Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM alpine:edge

ARG TARGETPLATFORM
ARG INSTALL_FFMPEG=false
ARG INSTALL_ARIA2=false
LABEL MAINTAINER="[email protected]"

WORKDIR /opt/alist/
Expand All @@ -10,13 +11,20 @@ RUN apk update && \
apk upgrade --no-cache && \
apk add --no-cache bash ca-certificates su-exec tzdata; \
[ "$INSTALL_FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \
[ "$INSTALL_ARIA2" = "true" ] && apk add --no-cache curl aria2 && \
mkdir -p /root/.aria2 && \
wget https://github.com/P3TERX/aria2.conf/archive/refs/heads/master.tar.gz -O /tmp/aria-conf.tar.gz && \
tar -zxvf /tmp/aria-conf.tar.gz -C /root/.aria2 && rm -f /tmp/aria-conf.tar.gz && \
sed -i 's|rpc-secret|#rpc-secret|g' /root/.aria2/aria2.conf && \
touch /root/.aria2/aria2.session && \
/root/.aria2/tracker.sh ; \
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
ENV PUID=0 PGID=0 UMASK=022 RUN_ARIA2=${INSTALL_ARIA2}
VOLUME /opt/alist/data/
EXPOSE 5244 5245
CMD [ "/entrypoint.sh" ]
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ chown -R ${PUID}:${PGID} /opt/alist/

umask ${UMASK}

if [ "$RUN_ARIA2" = "true" ]; then
exec su-exec ${PUID}:${PGID} nohup aria2c \
--enable-rpc \
--rpc-allow-origin-all \
--conf-path=/root/.aria2/aria2.conf \
>/dev/null 2>&1 &
fi

if [ "$1" = "version" ]; then
./alist version
else
Expand Down

0 comments on commit 5a2d25c

Please sign in to comment.