Skip to content

Commit be17211

Browse files
committed
feat: add dockerfile
1 parent fcc072e commit be17211

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM alpine:3.18
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+
RUN apk add --no-cache curl ca-certificates bash
10+
11+
WORKDIR /
12+
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 so 'docker compose up'
18+
# works out of the box. Users can override by mounting a host directory.
19+
RUN mkdir -p /usr/local/etc/aio && chmod 0755 /usr/local/etc/aio
20+
COPY all-in-one-bot.yml /usr/local/etc/aio/all-in-one-bot.yml
21+
22+
# Keep logs as a volume so logs can be persisted by the host if desired
23+
VOLUME ["/var/log/aio"]
24+
25+
ENV TZ=Asia/Shanghai
26+
27+
ENTRYPOINT ["/entrypoint.sh"]

docker-compose.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Docker Compose configuration for all-in-one-bot
2+
# The image is pulled from Docker Hub (uerax/aio:latest by default)
3+
# No need to build locally; just run: docker compose up -d
4+
5+
version: "3.8"
6+
7+
services:
8+
bot:
9+
image: uerax/aio:latest
10+
container_name: all-in-one-bot
11+
restart: unless-stopped
12+
volumes:
13+
# Optional: uncomment to override the default config with a host file
14+
- ./config:/usr/local/etc/aio:ro
15+
- ./logs:/var/log/aio
16+
networks:
17+
- botnet
18+
healthcheck:
19+
test: ["CMD-SHELL", "test -x /usr/local/bin/aio || exit 1"]
20+
interval: 30s
21+
timeout: 10s
22+
retries: 3
23+
24+
networks:
25+
botnet:
26+
driver: bridge

entrypoint.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
# Configurable variables:
5+
# ASSET_NAME - name of the release asset to download (default Aio-linux-amd64)
6+
# REPO - owner/repo (default uerax/all-in-one-bot)
7+
# RELEASE_URL - optional full URL to download (overrides REPO/ASSET_NAME)
8+
# CONFIG_PATH - path to config file passed to binary
9+
10+
ASSET_NAME=${ASSET_NAME:-Aio-linux-amd64}
11+
REPO=${REPO:-uerax/all-in-one-bot}
12+
RELEASE_URL=${RELEASE_URL:-}
13+
CONFIG_PATH=${CONFIG_PATH:-/usr/local/etc/aio/all-in-one-bot.yml}
14+
15+
BIN=/usr/local/bin/aio
16+
17+
download() {
18+
url=${RELEASE_URL}
19+
if [ -z "$url" ]; then
20+
url="https://github.com/${REPO}/releases/latest/download/${ASSET_NAME}"
21+
fi
22+
echo "Downloading $url ..."
23+
# retry a few times
24+
if ! curl -fSL --retry 3 --retry-delay 2 "$url" -o "$BIN"; then
25+
echo "Failed to download release asset: $url" >&2
26+
return 1
27+
fi
28+
chmod +x "$BIN"
29+
}
30+
31+
# Ensure config dir and logs exist
32+
mkdir -p "$(dirname "$CONFIG_PATH")" /var/log/aio
33+
34+
if [ ! -x "$BIN" ]; then
35+
if ! download; then
36+
echo "Download failed and no local binary present. Exiting." >&2
37+
exit 2
38+
fi
39+
fi
40+
41+
echo "Starting aio with config: $CONFIG_PATH"
42+
exec "$BIN" -c "$CONFIG_PATH"

0 commit comments

Comments
 (0)