|
1 | 1 | FROM alpine:3.18 |
2 | 2 |
|
3 | | -# Minimal runtime image. At container start the entrypoint downloads the |
4 | | -# latest release binary (Aio-linux-amd64 by default) and runs it. The image |
5 | | -# also includes a default `all-in-one-bot.yml` so the container can run |
6 | | -# without host-provided config; users can override by bind-mounting |
7 | | -# ./config -> /usr/local/etc/aio. |
8 | | - |
9 | 3 | RUN apk add --no-cache curl ca-certificates bash |
10 | 4 |
|
11 | 5 | WORKDIR / |
12 | 6 |
|
13 | | -# Copy entrypoint script that will download the release asset at runtime |
14 | | -COPY entrypoint.sh /entrypoint.sh |
15 | | -RUN chmod +x /entrypoint.sh |
16 | | - |
17 | | -# Provide a default config baked into the image. On first startup, entrypoint |
18 | | -# copies this to the host mount if it doesn't exist. Users can then edit |
19 | | -# ./config/all-in-one-bot.yml and restart the container. |
20 | | -RUN mkdir -p /usr/local/etc/aio && chmod 0755 /usr/local/etc/aio |
21 | | -COPY all-in-one-bot.yml /usr/local/etc/aio/all-in-one-bot.yml.default |
| 7 | +# 根据架构下载二进制文件、创建配置文件和日志目录 |
| 8 | +RUN set -e; \ |
| 9 | + ARCH=$(uname -m); \ |
| 10 | + if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "amd64" ]; then \ |
| 11 | + AIO_BIN="Aio-linux-amd64"; \ |
| 12 | + elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then \ |
| 13 | + AIO_BIN="Aio-linux-arm64"; \ |
| 14 | + else \ |
| 15 | + echo "Unsupported architecture: $ARCH"; exit 1; \ |
| 16 | + fi; \ |
| 17 | + mkdir -p /usr/local/bin /usr/local/etc/aio /var/log/aio; \ |
| 18 | + chmod 0755 /usr/local/etc/aio /var/log/aio; \ |
| 19 | + LATEST=$(curl -sL https://api.github.com/repos/uerax/all-in-one-bot/releases/latest | grep "tag_name" | cut -d '"' -f 4); \ |
| 20 | + curl -L "https://github.com/uerax/all-in-one-bot/releases/download/$LATEST/$AIO_BIN" -o /usr/local/bin/aio; \ |
| 21 | + chmod +x /usr/local/bin/aio; \ |
| 22 | + if [ ! -f /usr/local/etc/aio/all-in-one-bot.yml ]; then \ |
| 23 | + curl -L "https://raw.githubusercontent.com/uerax/all-in-one-bot/master/all-in-one-bot.yml" -o /usr/local/etc/aio/all-in-one-bot.yml; \ |
| 24 | + echo "Configuration downloaded. Please edit /usr/local/etc/aio/all-in-one-bot.yml and restart the container."; \ |
| 25 | + exit 0; \ |
| 26 | + fi |
22 | 27 |
|
23 | | -# Keep logs as a volume so logs can be persisted by the host if desired |
24 | 28 | VOLUME ["/var/log/aio"] |
25 | 29 |
|
26 | 30 | ENV TZ=Asia/Shanghai |
27 | 31 |
|
28 | | -ENTRYPOINT ["/entrypoint.sh"] |
| 32 | +CMD ["/usr/local/bin/aio", "-c", "/usr/local/etc/aio/all-in-one-bot.yml"] |
0 commit comments