Repository navigation
build(docker): run as non-root and pin base images by digest - #47
Merged
Merged
Conversation
Review F23: the image ran as root, used an editable install, and both python:3.12-slim and searxng/searxng:latest floated. - Dockerfile: base pinned to the python:3.12-slim multi-arch index digest; regular (non-editable) `pip install '.[extract]'`; a `pw` user (UID/GID 1000, matching compose's PW_UID/PW_GID default) and `USER 1000:1000`; /app/data pre-created pw-owned so a fresh named volume (the coordinator DB) is writable. - docker-compose.yml: searxng pinned to the latest index digest; the stale "image has no USER" note rewritten; a one-time chown command documented for coordinator volumes created by the old root image. Digests were read from the registry with `docker buildx imagetools inspect <image>:<tag>` on 2026-10-11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Review F23 (task T15): the image ran as root, used an editable install, and both base images floated (
python:3.12-slim,searxng/searxng:latest).Dockerfile
FROM python:3.12-slim@sha256:a6e34c598f2467ed0e9a8d349809fcd8b5c603269512df273a0bb1784edc11b1. This is the multi-arch index digest, so amd64 and arm64 both resolve. The tag stays for readability.pip install --no-cache-dir '.[extract]'. The package now sits in site-packages, root-owned and read-only to the runtime user.pwuser and group (UID/GID 1000, matching compose'sPW_UID/PW_GIDdefault) andUSER 1000:1000. The ID is numeric sorunAsNonRoot-style checks can verify it./app/datais pre-createdpw:pw 0700, so a fresh named volume mounted there (the coordinator'sPW_DB) inherits a writable owner.docker-compose.yml
searxng/searxng:latest@sha256:85492ba800a861e3e8ff6014c430e81369fe6ca766a9990595f616d1ce95b272(index digest).chownfor coordinator volumes created by the old root image. Without it, an existingpw-coordinator-dbvolume stays root-owned and the non-root coordinator can't write its DB.Digest provenance
Both digests were read from Docker Hub on 2026-10-11 with
docker buildx imagetools inspect python:3.12-slimanddocker buildx imagetools inspect searxng/searxng:latest(top-levelDigest:, media typeapplication/vnd.oci.image.index.v1+json). The python index resolves to3.12.15-slim-trixie(created 2026-10-06T01:55:50Z, docker-library/python@2a3b794). None of the digests were typed from memory.Verification (this VPS, rootless Docker 29.9.0 / buildx 0.38.0)
docker build --pull -t <probe> .→ exit 0. Rebuilt after the hadolint fixes → exit 0.docker run --rm <probe> id→uid=1000(pw) gid=1000(pw).HOME=/home/pw.Config.User=1000:1000.pworkers --helpOK. Writing/appfails withPermission denied(expected).docker run -p 127.0.0.1:<port>:8770 <probe>thencurl /→ 200.python -m passiveworkers.net.coordinator_app, a random 48-hexPW_TOKEN,PW_HOST=0.0.0.0):/healthz→ 200,/→ 200.coordinator.dbwas created owned by1000:1000.docker compose run --rm --user root --entrypoint chown coordinator -R pw:pw /app/data. Afterwards/app/dataandcoordinator.dbwere owned by1000and writable by the default user.PW_TOKEN=<placeholder> docker compose config -q→ exit 0.hadolint/hadolint@sha256:32dac941…viadocker run --rm -i) → exit 0. The first pass flagged DL3066 (non-numeric USER), now fixed, and DL3013 (pin pip versions). DL3013 is suppressed inline because the install target is the local project, not a registry package.ruff check . && pytest tests/ -q --cov=passiveworkers --cov-fail-under=75→ exit 0 (740 passed, 1 skipped,Total coverage: 83.38%). No Python changed.Not verified / notes
linux/amd64was built. arm64 resolves through the same index digest, but I didn't build it.dockerecosystem can do that, but adding it touches.github/dependabot.yml, which is outside this lane.ENV PW_SERVE_HOST=0.0.0.0(review F25's baredocker runexposure;serve.py's Host/Origin allow-list landed in fix(serve,judge): Host/Origin allow-list for the desk, data-name history handler, spotlight judge blocks #39/fix(serve,judge): exact-origin check, strict Host, PW_SERVE_ALLOWED_HOSTS; country inside spotlight #43).🤖 Generated with Claude Code