Skip to content

Commit d9a096b

Browse files
committed
fix: bug
1 parent be17211 commit d9a096b

File tree

4 files changed

+75
-10
lines changed

4 files changed

+75
-10
lines changed

.github/workflows/docker.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ name: Publish Docker image
1111

1212
on:
1313
push:
14-
tags:
15-
- 'v*'
1614
branches:
1715
- master
1816
release:

Dockerfile

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,67 @@ RUN apk add --no-cache curl ca-certificates bash
1010

1111
WORKDIR /
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.
1972
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
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
2376
VOLUME ["/var/log/aio"]

docker-compose.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ services:
1010
container_name: all-in-one-bot
1111
restart: unless-stopped
1212
volumes:
13-
# Optional: uncomment to override the default config with a host file
14-
- ./config:/usr/local/etc/aio:ro
13+
# Config directory: on first startup, if config doesn't exist,
14+
# entrypoint copies the default from image here. Edit the config
15+
# and restart the container with: docker compose restart bot
16+
- ./config:/usr/local/etc/aio
1517
- ./logs:/var/log/aio
1618
networks:
1719
- botnet

entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ download() {
3131
# Ensure config dir and logs exist
3232
mkdir -p "$(dirname "$CONFIG_PATH")" /var/log/aio
3333

34+
# On first startup, if host config doesn't exist, copy default from image
35+
if [ ! -f "$CONFIG_PATH" ]; then
36+
DEFAULT_CONFIG="/usr/local/etc/aio/all-in-one-bot.yml.default"
37+
if [ -f "$DEFAULT_CONFIG" ]; then
38+
echo "First startup: Creating default config at $CONFIG_PATH"
39+
cp "$DEFAULT_CONFIG" "$CONFIG_PATH"
40+
echo "Config created from image default. Please edit and restart container."
41+
else
42+
echo "WARNING: No config file found and no default available." >&2
43+
fi
44+
fi
45+
3446
if [ ! -x "$BIN" ]; then
3547
if ! download; then
3648
echo "Download failed and no local binary present. Exiting." >&2

0 commit comments

Comments
 (0)