File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,15 +7,18 @@ RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /TinyUptimeRobot .
77
88# ---- runtime stage ----
99FROM alpine:3.20
10- RUN apk add --no-cache ca-certificates && adduser -D monitor \
11- && mkdir -p /app/data && chown -R monitor:monitor /app
12-
10+ RUN apk add --no-cache ca-certificates su-exec \
11+ && adduser -D monitor \
12+ && mkdir -p /app/data \
13+ && chown -R monitor:monitor /app
1314WORKDIR /app
1415COPY --from=build /TinyUptimeRobot /app/TinyUptimeRobot
15- USER monitor
16+ COPY entrypoint.sh /app/entrypoint.sh
17+ RUN chmod +x /app/entrypoint.sh
18+ # runs as root only to fix /app/data ownership on bind mounts, then drops to monitor
19+ ENTRYPOINT ["/app/entrypoint.sh" ]
20+
1621ENV TARGETS_FILE=/app/targets.txt \
1722 LOG_FILE=/app/data/status.txt \
1823 CHECK_INTERVAL=60s \
1924 HTTP_TIMEOUT=10s
20- VOLUME ["/app/data" ]
21- ENTRYPOINT ["/app/TinyUptimeRobot" ]
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ # Fix ownership of the data dir (bind mounts are often owned by root),
3+ # then drop privileges and run as the unprivileged monitor user.
4+ set -e
5+
6+ DATA_DIR=" $( dirname " ${LOG_FILE:-/ app/ data/ status.txt} " ) "
7+ mkdir -p " $DATA_DIR " 2> /dev/null || true
8+ chown -R monitor:monitor " $DATA_DIR " 2> /dev/null || true
9+
10+ # if the targets file is read-only and unreadable, that's fine — the app will error clearly
11+ exec su-exec monitor:monitor /app/TinyUptimeRobot " $@ "
You can’t perform that action at this time.
0 commit comments