Skip to content

Commit c730e70

Browse files
committed
fix: use USER directive instead of su-exec entrypoint for media permissions
The entrypoint script running mkdir/chown as root fails when the container runtime (e.g. Cosmos Cloud) forces a non-root user. Since we use Docker named volumes (not bind mounts), there's no UID mismatch to fix at runtime. Switch to a simple USER directive -- the directory is created and chowned at build time, which is sufficient. Removes su-exec dependency and docker-entrypoint.sh usage. https://claude.ai/code/session_0153nX7vQSjEFPpZTgZdDmu5
1 parent e89d260 commit c730e70

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

Dockerfile

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o /chronicle ./cmd/server
4242
# --- Stage 3: Runtime ---
4343
FROM alpine:3.20
4444

45-
# Install CA certificates for HTTPS calls (if needed), timezone data, and
46-
# su-exec for dropping privileges in the entrypoint.
47-
RUN apk add --no-cache ca-certificates tzdata su-exec
45+
# Install CA certificates for HTTPS calls (if needed) and timezone data.
46+
RUN apk add --no-cache ca-certificates tzdata
4847

4948
# Create non-root user for runtime security.
5049
RUN adduser -D -H -s /sbin/nologin chronicle
@@ -63,16 +62,10 @@ COPY --from=builder /src/db/migrations /app/db/migrations
6362
# Mount a volume at /app/data to persist media across container rebuilds.
6463
RUN mkdir -p /app/data/media && chown -R chronicle:chronicle /app/data
6564

66-
# Copy entrypoint script that fixes bind-mount permissions before dropping to
67-
# the non-root chronicle user.
68-
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
69-
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
70-
7165
WORKDIR /app
7266

73-
# Container starts as root so the entrypoint can fix bind-mount ownership,
74-
# then drops to the chronicle user via su-exec.
75-
ENTRYPOINT ["docker-entrypoint.sh"]
67+
# Run as the unprivileged chronicle user.
68+
USER chronicle
7669

7770
# The Go binary serves HTTP directly on this port.
7871
EXPOSE 8080

0 commit comments

Comments
 (0)