@@ -42,8 +42,9 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o /chronicle ./cmd/server
4242# --- Stage 3: Runtime ---
4343FROM alpine:3.20
4444
45- # Install CA certificates for HTTPS calls (if needed) and timezone data.
46- RUN apk add --no-cache ca-certificates tzdata
45+ # Install CA certificates for HTTPS calls, timezone data, and su-exec for
46+ # dropping privileges in the entrypoint.
47+ RUN apk add --no-cache ca-certificates tzdata su-exec
4748
4849# Create non-root user for runtime security.
4950RUN adduser -D -H -s /sbin/nologin chronicle
@@ -64,8 +65,10 @@ RUN mkdir -p /app/data/media && chown -R chronicle:chronicle /app/data
6465
6566WORKDIR /app
6667
67- # Run as the unprivileged chronicle user.
68- USER chronicle
68+ # Copy entrypoint script that fixes bind-mount permissions, then drops to
69+ # the unprivileged chronicle user via su-exec.
70+ COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
71+ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
6972
7073# The Go binary serves HTTP directly on this port.
7174EXPOSE 8080
@@ -74,5 +77,7 @@ EXPOSE 8080
7477HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
7578 CMD wget -qO- http://localhost:8080/healthz || exit 1
7679
77- # Run the Chronicle server.
80+ # Container starts as root; the entrypoint fixes permissions then exec's
81+ # the server as the chronicle user.
82+ ENTRYPOINT ["docker-entrypoint.sh" ]
7883CMD ["chronicle" ]
0 commit comments