Repository navigation
fix(docker): run the test image as a non-root user - #46
Merged
Merged
Conversation
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.
The Dockerfiles that DockSec flags are fixed: the root one, the ones under
examples/and, in fastapi-guard, the live-smoke one. None installs apt packages any more, uv comes from the official image at an exact tag, every image runs as a numeric non-rootUSERand has a HEALTHCHECK.docksec.ymlnow also watches**/Dockerfile, because DockSec runstrivy configover the whole tree and keeps every file namedDockerfile(findings.py:182-185), so a change to a nested file has to trigger the scan.Closes all open DockSec alerts (rule ids, alert numbers): DS002 (#2, #3), DS026 (#10, #11), DS029 (#5), DL3008 (#7), DL3013 (#8), DL3042 (#9).
Root Dockerfile:
pip install uvbecameCOPY --from=ghcr.io/astral-sh/uv:0.13.4 /uv /uvx /bin/, and I droppedPIP_NO_CACHE_DIR=false, which only configured that pip call.app(uid 10001) owns/app,USER 10001comes beforeuv syncso the venv and/app/dataare writable.http://127.0.0.1:8000/with python and counts any HTTP answer as alive. The one-shot test runner would report a meaningless unhealthy state, socompose.ymlsetshealthcheck: disable: trueon the test service.Nested Dockerfiles:
examples/simple_app/Dockerfile: apt block dropped, userapp(uid 10001),USER 10001, HEALTHCHECK. Run through its owndocker-compose.yml:healthy,GET /200 from the host and from inside the container,uid=10001.Verification (python 3.10, own compose projects, Redis without a host port, one run at a time):
healthy,GET /200,uid=10001(app). The service command incompose.yml(python examples/simple_app/main.py) fails on master and on this branch alike (No module named 'tornadoapi_guard'), so I started it withenv PYTHONPATH=/app python examples/simple_app/main.py.config --file-patterns dockerfile:Dockerfileover the repo: 27 successes, 0 failures for every Dockerfile.refs/pull/46/merge:results_count0 and 0 open alerts on that ref.Not verified: python versions other than 3.10, and the bind-mounted examples (
./:/app) on a Linux host, where a host-owned directory is not writable by uid 10001.