Container sets its data directory's owner and mode itself (closes #340)
check / check (push) Successful in 4m12s
check / check (push) Successful in 4m12s
The image now starts as root through deploy/docker-entrypoint.sh, which creates DATA_DIR if it is missing, gives the directory and anything in it owned by another user to webhooker, sets the directory to 0750, and runs the command as webhooker with su-exec. An empty root-owned bind mount, or data left by another uid, now works with no step on the host. Started with --user, the script only runs the command. The README drops every instruction to create or chown the host directory; the upaas volume bullet names only the path. Model: opus-5-5
This commit is contained in:
+9
-2
@@ -88,7 +88,9 @@ RUN CGO_ENABLED=1 make build VERSION="$VERSION" GO_LDFLAGS='-extldflags "-static
|
||||
# alpine:3.21, 2026-03-17
|
||||
FROM alpine:3.21@sha256:c3f8e73fdb79deaebaa2037150150191b9dcbfba68b4a46d70103204c53f4709
|
||||
|
||||
RUN apk --no-cache add ca-certificates
|
||||
# su-exec 0.2-r3 (Alpine 3.21), 2026-09-29: the entrypoint runs the app
|
||||
# as webhooker with it.
|
||||
RUN apk --no-cache add ca-certificates su-exec=0.2-r3
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -g 1000 -S webhooker && \
|
||||
@@ -99,13 +101,17 @@ WORKDIR /app
|
||||
# Copy binary from builder
|
||||
COPY --from=builder /build/bin/webhooker /app/webhooker
|
||||
|
||||
# Not under /app, which belongs to webhooker: this script runs as root.
|
||||
COPY deploy/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
# Create data directory for all SQLite databases (main app DB +
|
||||
# per-webhook event DBs). DATA_DIR defaults to /var/lib/webhooker.
|
||||
RUN mkdir -p /var/lib/webhooker
|
||||
|
||||
RUN chown -R webhooker:webhooker /app /var/lib/webhooker
|
||||
|
||||
USER webhooker
|
||||
# No USER: the entrypoint starts as root to make the data directory
|
||||
# webhooker's, then runs the app as webhooker.
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
@@ -124,4 +130,5 @@ ENV BIND_ADDRESS=0.0.0.0
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/.well-known/healthcheck || exit 1
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||
CMD ["/app/webhooker"]
|
||||
|
||||
Reference in New Issue
Block a user