Repository navigation
build(agent): run API and worker containers as non-root - #8
Merged
Merged
Conversation
- Record the approved plan for clearing DS-0002 (api/worker as appuser). - Planning pass only: no Dockerfile, workflow, or app code touched.
- Create appuser (uid 10001) in the base stage and point HOME/HF_HOME/ UV_CACHE_DIR at its home before the worker model bake, so silero and turn-detector weights land under the runtime user's cache. - chown /app and /home/appuser, then USER appuser in the api and worker stages; CMDs and compose commands stay unchanged (`uv run` still works). - CI docker-build: build/load both agent targets, assert uid 10001 on each, boot the API and poll /health, and import the worker module as appuser.
- Both agent images verified as appuser/10001; API /health, trace writes, worker import, and an offline weight re-bake all pass. - Trivy misconfig HIGH/CRITICAL is 0: DS-0002 cleared. CI now covers both targets plus non-root, health, and worker-import checks.
- Add the misconfig scanner to the Trivy security gate now that DS-0002 (agent image root user) is fixed; the exact gate command exits 0 with 0 findings on every target. - Correct the stale comment claiming the root-user misconfig is accepted. - Worklog: record the deviation, the exact gate result, and the CI change.
- Add the misconfig-gate commit to the evidence commit list.
- The docker-build job now loads four images, including the multi-GB worker, while buildkit holds their layers; drop preinstalled toolchains the job never uses so the worker export cannot run the runner out of disk (the local first export hit exactly that). - Worklog: record the mitigation and that this branch's workflow has not run yet.
- Create appuser and chown only the empty /app in base, then USER appuser before every install and the model bake; COPY --chown keeps the lockfiles and source appuser-owned. - Removes the ~3.2GB chown layer duplicated in both images: worker 6.66GB -> 3.46GB, api 2.31GB -> 1.29GB; local builds 5m04s -> 1m38s (worker) and 2m00s -> 1m11s (api). - uv sync and the model bake still run clean as appuser; runtime CMDs unchanged.
- Worker check now runs the baked venv directly with --network none and HF_HUB_OFFLINE=1: imports the worker, silero and turn_detector, calls Plugin.download_files() for every registered plugin and silero.VAD.load(), and asserts uid 10001. No `uv run`. - API smoke writes a real trace with .venv/bin/python and asserts the JSONL exists, contains trace_start, and is owned by uid 10001.
- Findings: duplicated recursive chown layers; worker proof via `uv run` without offline/baked-weight coverage; health-only API smoke. - Fixes and re-run evidence against the final images, including image sizes/history, offline VAD load, and trace ownership.
- PR #8 exists; record that this round is its head and that its CI run for the new head still needs checking.
- Offline: `.venv/bin/python -m deepinterview_agent.worker --help` with --network none and HF_HUB_OFFLINE=1, run against the already-built worker image (no rebuild). - Online: the compose/CMD path `uv run python -c "import deepinterview_agent.worker, livekit.plugins.silero"` with the network available. - Both steps were executed verbatim locally against the final image: CLI exit 0 with its commands listed; uv run exit 0 after syncing dev deps.
- Final-review finding, the two new CI steps, and the verbatim local evidence against the existing final worker image (no rebuild).
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.
Why
The agent API and LiveKit worker containers were the last accepted HIGH misconfiguration (
DS-0002: running as root). This change removes that risk and makes both runtime stages non-root.Changes
appuser(UID 10001) before the worker model bake.USER appuserin bothapiandworkerstages./health, and imports the worker asappuser.vuln,secret,misconfig;DS-0002is cleared rather than ignored.Verification
appuser./healthreturns 200 with no permission errors.appuser.appuser; baked model cache is appuser-owned and works offline.Full evidence:
WORKLOG.md.