Skip to content

Commit 0368126

Browse files
committed
fix: make container UID/GID configurable for bind-mount compatibility
When using bind mounts, the host directory's UID/GID must match the container user. Add PUID/PGID build args (default 1000) so users can build with --build-arg PUID=$(id -u) --build-arg PGID=$(id -g) to match their host user. Compose passes these from .env or shell vars. https://claude.ai/code/session_0153nX7vQSjEFPpZTgZdDmu5
1 parent c730e70 commit 0368126

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ FROM alpine:3.20
4646
RUN apk add --no-cache ca-certificates tzdata
4747

4848
# Create non-root user for runtime security.
49-
RUN adduser -D -H -s /sbin/nologin chronicle
49+
# PUID/PGID let you match the host directory owner when using bind mounts.
50+
# Build with: docker build --build-arg PUID=$(id -u) --build-arg PGID=$(id -g) .
51+
ARG PUID=1000
52+
ARG PGID=1000
53+
RUN addgroup -g "$PGID" chronicle \
54+
&& adduser -D -H -s /sbin/nologin -G chronicle -u "$PUID" chronicle
5055

5156
# Copy the compiled binary.
5257
COPY --from=builder /chronicle /usr/local/bin/chronicle

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ services:
1919
build:
2020
context: .
2121
dockerfile: Dockerfile
22+
args:
23+
# Match container UID/GID to the host user that owns the bind-mount
24+
# directory. Override in .env or shell: PUID=$(id -u) PGID=$(id -g)
25+
PUID: ${PUID:-1000}
26+
PGID: ${PGID:-1000}
2227
container_name: chronicle
2328
ports:
2429
- "8080:8080"

0 commit comments

Comments
 (0)