From 818ac9b2407fc509e77ba1a1e21fe83a21bf324e Mon Sep 17 00:00:00 2001 From: Abner <22141172+Silentely@users.noreply.github.com> Date: Wed, 9 Jul 2025 20:30:29 +0800 Subject: [PATCH] feat: remote config --- Dockerfile | 8 +++++++- entrypoint.sh | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 5b407d6..34c21d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,8 +23,14 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ FROM alpine:latest +RUN apk add --no-cache curl + WORKDIR /app COPY --from=builder /app/saveany-bot . +COPY entrypoint.sh . -ENTRYPOINT ["/app/saveany-bot"] +RUN chmod +x /app/saveany-bot && \ + chmod +x /app/entrypoint.sh + +ENTRYPOINT ["/app/entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..f89fb54 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ -n "$CONFIG_URL" ]; then + echo "[INFO] Downloading config from $CONFIG_URL" + if curl -sSLo /app/config.toml "$CONFIG_URL"; then + echo "[INFO] Configuration downloaded successfully" + else + echo "[ERROR] Failed to download config from $CONFIG_URL" + exit 1 + fi +fi + +if [ ! -f /app/config.toml ]; then + echo "[ERROR] Missing config.toml: 请通过挂载或 CONFIG_URL 提供配置文件" + exit 1 +fi + +exec /app/saveany-bot \ No newline at end of file