diff --git a/Dockerfile b/Dockerfile index af1781b..adf55c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,9 +12,16 @@ COPY go.mod go.sum ./ RUN go mod download COPY . . COPY --from=admin /src/internal/adminui/dist ./internal/adminui/dist -RUN CGO_ENABLED=0 go build -o /parsimony ./cmd/parsimony +RUN CGO_ENABLED=0 go build -o /parsimony ./cmd/parsimony && mkdir /data -FROM gcr.io/distroless/static-debian12 +# Run as the unprivileged "nonroot" user (uid 65532). /data is the only writable path: +# the database and its WAL files live there. A new named volume inherits this ownership; +# for a bind mount, make the host directory writable by uid 65532. +FROM gcr.io/distroless/static-debian12:nonroot COPY --from=build /parsimony /parsimony +COPY --from=build --chown=65532:65532 /data /data VOLUME /data -ENTRYPOINT ["/parsimony", "-config", "/data/parsimony.yaml"] +EXPOSE 2424 8080 8081 +USER 65532:65532 +# Mount the config read-only at /etc/parsimony/parsimony.yaml; keep "db: /data/parsimony.db" in it. +ENTRYPOINT ["/parsimony", "-config", "/etc/parsimony/parsimony.yaml"] diff --git a/README.md b/README.md index 59daa1d..7306b36 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,22 @@ the unsubscribe links in every message use it. Keep the `api` listener private. curl -H "Authorization: Bearer $PARSIMONY_API_TOKEN" -d '{"name":"dev","domain":"example.org","title":"Dev"}' localhost:8080/api/v1/lists ``` +## Docker + +The image runs as an unprivileged user (uid 65532) and works with a read-only root filesystem. +Config is mounted read-only; the only writable path is the `/data` volume (the database). + +``` +docker build -t parsimony . +docker run -d --name parsimony --read-only --cap-drop ALL \ + -v parsimony-data:/data \ + -v $PWD/parsimony.yaml:/etc/parsimony/parsimony.yaml:ro \ + -e PARSIMONY_API_TOKEN=... -p 2424:2424 -p 8080:8080 -p 8081:8081 parsimony +``` + +Use `db: /data/parsimony.db` in the config. A new named volume gets the right ownership by itself; +for a bind mount, make the host directory writable by uid 65532. + ## Delivery and the queue LMTP answers `250` when the post is in the queue, so a down relay never bounces mail back to Postfix.