8000 feat(docker release): improve aria2 image, add aio image (#7750) · AlistGo/alist@4dce53d · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 4dce53d

Browse files
Mmx233GoodbyeNJN
andauthored
feat(docker release): improve aria2 image, add aio image (#7750)
* build: add argument INSTALL_ARIA2 to dockerfile * feat: run aria2 in main entrypoint * feat(ci): environment matrix for docker release * improve(ci): allow overwrite artifacts in docker release * fix(ci): permission of alist binary in docker; entrypoint logic * improve(aria2): move aria2 data to /opt/aria2; fix permission issues References: AlistGo/with_aria2#13 Co-authored-by: GoodbyeNJN <cc@fuckwall.cc> * fix(ci): aio image is not taking effect * fix(build): tar command in aria2 installation process (cherry picked from commit 6472854) --------- Co-authored-by: GoodbyeNJN <cc@fuckwall.cc>
1 parent 365fc40 commit 4dce53d

File tree

4 files changed

+100
-62
lines changed

4 files changed

+100
-62
lines changed

.github/workflows/release_docker.yml

+60-56
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ on:
55
tags:
66
- 'v*'
77

8+
env:
9+
IMAGE_REGISTRY: 'xhofe/alist'
10+
REGISTRY_USERNAME: 'xhofe'
11+
REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
12+
ARTIFACT_NAME: 'binaries_docker_release'
13+
RELEASE_PLATFORMS: 'linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x,linux/ppc64le,linux/riscv64'
14+
815
jobs:
9-
release_docker:
10-
name: Release Docker
16+
build_binary:
17+
name: Build Binaries for Docker Release
1118
runs-on: ubuntu-latest
1219
steps:
1320
- name: Checkout
@@ -31,11 +38,45 @@ jobs:
3138
- name: Build go binary
3239
run: bash build.sh release docker-multiplatform
3340

34-
- name: Docker meta
35-
id: meta
36-
uses: docker/metadata-action@v5
41+
- name: Upload artifacts
42+
uses: actions/upload-artifact@v4
3743
with:
38-
images: xhofe/alist
44+
name: ${{ env.ARTIFACT_NAME }}
45+
overwrite: true
46+
path: |
47+
build/
48+
!build/*.tgz
49+
!build/musl-libs/**
50+
51+
release_docker:
52+
needs: build_binary
53+
name: Release Docker image
54+
runs-on: ubuntu-latest
55+
strategy:
56+
matrix:
57+
image: ["latest", "ffmpeg", "aria2", "aio"]
58+
include:
59+
- image: "latest"
60+
build_arg: ""
61+
tag_favor: ""
62+
- image: "ffmpeg"
63+
build_arg: INSTALL_FFMPEG=true
64+
tag_favor: "suffix=-ffmpeg, class="pl-pds">"
65+
- image: "aria2"
66+
build_arg: INSTALL_ARIA2=true
67+
tag_favor: "suffix=-aria2, EDBE ue"
68+
- image: "aio"
69+
build_arg: |
70+
INSTALL_FFMPEG=true
71+
INSTALL_ARIA2=true
72+
tag_favor: "suffix=-aio, class="pl-pds">"
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v4
76+
- uses: actions/download-artifact@v4
77+
with:
78+
name: ${{ env.ARTIFACT_NAME }}
79+
path: 'build/'
3980

4081
- name: Set up QEMU
4182
uses: docker/setup-qemu-action@v3
@@ -46,63 +87,26 @@ jobs:
4687
- name: Login to DockerHub
4788
uses: docker/login-action@v3
4889
with:
49-
username: xhofe
50-
password: ${{ secrets.DOCKERHUB_TOKEN }}
90+
username: ${{ env.REGISTRY_USERNAME }}
91+
password: ${{ env.REGISTRY_PASSWORD }}
5192

52-
- name: Build and push
53-
id: docker_build
54-
uses: docker/build-push-action@v6
55-
with:
56-
context: .
57-
file: Dockerfile.ci
58-
push: true
59-
tags: ${{ steps.meta.outputs.tags }}
60-
labels: ${{ steps.meta.outputs.labels }}
61-
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x,linux/ppc64le,linux/riscv64
62-
63-
- name: Docker meta with ffmpeg
64-
id: meta-ffmpeg
93+
- name: Docker meta
94+
id: meta
6595
uses: docker/metadata-action@v5
6696
with:
67-
images: xhofe/alist
97+
images: ${{ env.IMAGE_REGISTRY }}
6898
flavor: |
6999
latest=true
70-
suffix=-ffmpeg,>
71-
72-
- name: Build and push with ffmpeg
73-
id: docker_build_ffmpeg
100+
${{ matrix.tag_favor }}
101+
102+
- name: Build and push
103+
id: docker_build
74104
uses: docker/build-push-action@v6
75105
with:
76106
context: .
77107
file: Dockerfile.ci
78108
push: true
79-
tags: ${{ steps.meta-ffmpeg.outputs.tags }}
80-
labels: ${{ steps.meta-ffmpeg.outputs.labels }}
81-
build-args: INSTALL_FFMPEG=true
82-
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x,linux/ppc64le,linux/riscv64
83-
84-
release_docker_with_aria2:
85-
needs: release_docker
86-
name: Release docker with aria2
87-
runs-on: ubuntu-latest
88-
steps:
89-
- name: Checkout repo
90-
uses: actions/checkout@v4
91-
with:
92-
repository: alist-org/with_aria2
93-
ref: main
94-
persist-credentials: false
95-
fetch-depth: 0
96< 10000 span class="diff-text-marker">-
97-
- name: Add tag
98-
run: |
99-
git config --local user.email "bot@nn.ci"
100-
git config --local user.name "IlaBot"
101-
git tag -a ${{ github.ref_name }} -m "release ${{ github.ref_name }}"
102-
103-
- name: Push tags
104-
uses: ad-m/github-push-action@master
105-
with:
106-
github_token: ${{ secrets.MY_TOKEN }}
107-
branch: main
108-
repository: alist-org/with_aria2
109+
build-args: ${{ matrix.build_arg }}
110+
tags: ${{ steps.meta.outputs.tags }}
111+
labels: ${{ steps.meta.outputs.labels }}
112+
platforms: ${{ env.RELEASE_PLATFORMS }}

Dockerfile

+15-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ RUN bash build.sh release docker
1010
FROM alpine:edge
1111

1212
ARG INSTALL_FFMPEG=false
13+
ARG INSTALL_ARIA2=false
1314
LABEL MAINTAINER="i@nn.ci"
1415

1516
WORKDIR /opt/alist/
@@ -18,13 +19,25 @@ RUN apk update && \
1819
apk upgrade --no-cache && \
1920
apk add --no-cache bash ca-certificates su-exec tzdata; \
2021
[ "$INSTALL_FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \
22+
[ "$INSTALL_ARIA2" = "true" ] && apk add --no-cache curl aria2 && \
23+
mkdir -p /opt/aria2/.aria2 && \
24+
wget https://github.com/P3TERX/aria2.conf/archive/refs/heads/master.tar.gz -O /tmp/aria-conf.tar.gz && \
25+
tar -zxvf /tmp/aria-conf.tar.gz -C /opt/aria2/.aria2 --strip-components=1 && rm -f /tmp/aria-conf.tar.gz && \
26+
sed -i 's|rpc-secret|#rpc-secret|g' /opt/aria2/.aria2/aria2.conf && \
27+
sed -i 's|/root/.aria2|/opt/aria2/.aria2|g' /opt/aria2/.aria2/aria2.conf && \
28+
sed -i 's|/root/.aria2|/opt/aria2/.aria2|g' /opt/aria2/.aria2/script.conf && \
29+
sed -i 's|/root|/opt/aria2|g' /opt/aria2/.aria2/aria2.conf && \
30+
sed -i 's|/root|/opt/aria2|g' /opt/aria2/.aria2/script.conf && \
31+
touch /opt/aria2/.aria2/aria2.session && \
32+
/opt/aria2/.aria2/tracker.sh ; \
2133
rm -rf /var/cache/apk/*
2234

2335
COPY --from=builder /app/bin/alist ./
2436
COPY entrypoint.sh /entrypoint.sh
25-
RUN chmod +x /entrypoint.sh && /entrypoint.sh version
37+
RUN chmod +x /opt/alist/alist && \
38+
chmod +x /entrypoint.sh && /entrypoint.sh version
2639

27-
ENV PUID=0 PGID=0 UMASK=022
40+
ENV PUID=0 PGID=0 UMASK=022 RUN_ARIA2=${INSTALL_ARIA2}
2841
VOLUME /opt/alist/data/
2942
EXPOSE 5244 5245
3043
CMD [ "/entrypoint.sh" ]

Dockerfile.ci

+15-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FROM alpine:edge
22

33
ARG TARGETPLATFORM
44
ARG INSTALL_FFMPEG=false
5+
ARG INSTALL_ARIA2=false
56
LABEL MAINTAINER="i@nn.ci"
67

78
WORKDIR /opt/alist/
@@ -10,13 +11,25 @@ RUN apk update && \
1011
apk upgrade --no-cache && \
1112
apk add --no-cache bash ca-certificates su-exec tzdata; \
1213
[ "$INSTALL_FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \
14+
[ "$INSTALL_ARIA2" = "true" ] && apk add --no-cache curl aria2 && \
15+
mkdir -p /opt/aria2/.aria2 && \
16+
wget https://github.com/P3TERX/aria2.conf/archive/refs/heads/master.tar.gz -O /tmp/aria-conf.tar.gz && \
17+
tar -zxvf /tmp/aria-conf.tar.gz -C /opt/aria2/.aria2 --strip-components=1 && rm -f /tmp/aria-conf.tar.gz && \
18+
sed -i 's|rpc-secret|#rpc-secret|g' /opt/aria2/.aria2/aria2.conf && \
19+
sed -i 's|/root/.aria2|/opt/aria2/.aria2|g' /opt/aria2/.aria2/aria2.conf && \
20+
sed -i 's|/root/.aria2|/opt/aria2/.aria2|g' /opt/aria2/.aria2/script.conf && \
21+
sed -i 's|/root|/opt/aria2|g' /opt/aria2/.aria2/aria2.conf && \
22+
sed -i 's|/root|/opt/aria2|g' /op F438 t/aria2/.aria2/script.conf && \
23+
touch /opt/aria2/.aria2/aria2.session && \
24+
/opt/aria2/.aria2/tracker.sh ; \
1325
rm -rf /var/cache/apk/*
1426

1527
COPY /build/${TARGETPLATFORM}/alist ./
1628
COPY entrypoint.sh /entrypoint.sh
17-
RUN chmod +x /entrypoint.sh && /entrypoint.sh version
29+
RUN chmod +x /opt/alist/alist && \
30+
chmod +x /entrypoint.sh && /entrypoint.sh version
1831

19-
ENV PUID=0 PGID=0 UMASK=022
32+
ENV PUID=0 PGID=0 UMASK=022 RUN_ARIA2=${INSTALL_ARIA2}
2033
VOLUME /opt/alist/data/
2134
EXPOSE 5244 5245
2235
CMD [ "/entrypoint.sh" ]

entrypoint.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
#!/bin/bash
22

3-
chown -R ${PUID}:${PGID} /opt/alist/
4-
53
umask ${UMASK}
64

75
if [ "$1" = "version" ]; then
86
./alist version
97
else
8+
if [ "$RUN_ARIA2" = "true" ]; then
9+
chown -R ${PUID}:${PGID} /opt/aria2/
10+
exec su-exec ${PUID}:${PGID} nohup aria2c \
11+
--enable-rpc \
12+
--rpc-allow-origin-all \
13+
--conf-path=/opt/aria2/.aria2/aria2.conf \
14+
>/dev/null 2>&1 &
15+
fi
16+
17+
chown -R ${PUID}:${PGID} /opt/alist/
1018
exec su-exec ${PUID}:${PGID} ./alist server --no-prefix
1119
fi

0 commit comments

Comments
 (0)
0