@@ -10,14 +10,67 @@ RUN apk add --no-cache curl ca-certificates bash
1010
1111WORKDIR /
1212
13- # Copy entrypoint script that will download the release asset at runtime
14- COPY entrypoint.sh /entrypoint.sh
15- RUN chmod +x /entrypoint.sh
13+ # Create entrypoint script inline to ensure Unix line endings and proper permissions
14+ RUN cat > /entrypoint.sh << 'EOF'
15+ # !/bin/sh
16+ set -eu
1617
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.
18+ # Configurable variables:
19+ # ASSET_NAME - name of the release asset to download (default Aio-linux-amd64)
20+ # REPO - owner/repo (default uerax/all-in-one-bot)
21+ # RELEASE_URL - optional full URL to download (overrides REPO/ASSET_NAME)
22+ # CONFIG_PATH - path to config file passed to binary
23+
24+ ASSET_NAME=${ASSET_NAME:-Aio-linux-amd64}
25+ REPO=${REPO:-uerax/all-in-one-bot}
26+ RELEASE_URL=${RELEASE_URL:-}
27+ CONFIG_PATH=${CONFIG_PATH:-/usr/local/etc/aio/all-in-one-bot.yml}
28+
29+ BIN=/usr/local/bin/aio
30+
31+ download() {
32+ url=${RELEASE_URL}
33+ if [ -z "$url" ]; then
34+ url="https://github.com/${REPO}/releases/latest/download/${ASSET_NAME}"
35+ fi
36+ echo "Downloading $url ..."
37+ if ! curl -fSL --retry 3 --retry-delay 2 "$url" -o "$BIN" ; then
38+ echo "Failed to download release asset: $url" >&2
39+ return 1
40+ fi
41+ chmod +x "$BIN"
42+ }
43+
44+ mkdir -p "$(dirname " $CONFIG_PATH")" /var/log/aio
45+
46+ if [ ! -f "$CONFIG_PATH" ]; then
47+ DEFAULT_CONFIG="/usr/local/etc/aio/all-in-one-bot.yml.default"
48+ if [ -f "$DEFAULT_CONFIG" ]; then
49+ echo "First startup: Creating default config at $CONFIG_PATH"
50+ cp "$DEFAULT_CONFIG" "$CONFIG_PATH"
51+ echo "Config created from image default. Please edit and restart container."
52+ else
53+ echo "WARNING: No config file found and no default available." >&2
54+ fi
55+ fi
56+
57+ if [ ! -x "$BIN" ]; then
58+ if ! download; then
59+ echo "Download failed and no local binary present. Exiting." >&2
60+ exit 2
61+ fi
62+ fi
63+
64+ echo "Starting aio with config: $CONFIG_PATH"
65+ exec "$BIN" -c "$CONFIG_PATH"
66+ EOF
67+ chmod +x /entrypoint.sh
68+
69+ # Provide a default config baked into the image. On first startup, entrypoint
70+ # copies this to the host mount if it doesn't exist. Users can then edit
71+ # ./config/all-in-one-bot.yml and restart the container.
1972RUN 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
73+ COPY all-in-one-bot.yml /usr/local/etc/aio/all-in-one-bot.yml.default
2174
2275# Keep logs as a volume so logs can be persisted by the host if desired
2376VOLUME ["/var/log/aio" ]
0 commit comments