fix(docker): real multi-stage image with HEALTHCHECK + relocatable config (#73)#80
Merged
Merged
Conversation
…nfig (#73) The Dockerfile was the single-stage editable-install skeleton with no HEALTHCHECK, while the project status table claimed the production image had landed. Make the claim true. - Multi-stage build: the builder compiles a non-editable install into /opt/venv and pre-downloads the embedding model; the slim runtime copies only those artifacts (no build tooling leaks), runs non-root, and bakes a /healthz HEALTHCHECK (liveness — /readyz depends on external deps). - The non-editable install relocates the package into site-packages, which broke the per-env YAML loader's __file__-relative config-dir resolution (it resolved to site-packages/config, not the COPY'd /app/config — a silent no-op). Add a SENTINEL_CONFIG_DIR override and point the image at /app/config. - CI never builds the app image, so a contract test guards the structural claims (multistage, copy-from-builder, HEALTHCHECK, non-root, no editable install); a regression test guards config-dir resolution. Verified locally: image builds, runs as `sentinel`, imports build_app, model cache present (1.3G), HEALTHCHECK in metadata, and load_settings() resolves config inside the container. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 16, 2026
JumpTechCode
added a commit
that referenced
this pull request
Jun 16, 2026
…ion from #80) (#82) The multistage image (#80) switched to a non-editable `pip install .`. setuptools packages only *.py by default, so `sentinel/diagnosis/prompts/v1.md` (+ its `.sha256` baseline) — read at boot by PromptBundle.load via a package-relative path — was dropped from the wheel, and the production image crashed on startup: FileNotFoundError: .../site-packages/sentinel/diagnosis/prompts/v1.md The #80 verification used a build_app() import smoke, which doesn't run the lifespan where PromptBundle.load lives — so the crash only surfaced on a real container boot. - Declare the prompts as package-data so the wheel ships them. The eval corpus/cassettes are deliberately left out (dev/CI-only, run from source). - Contract test guards the declaration (CI never builds the wheel). Verified: `pip wheel .` now contains v1.md + v1.sha256; the rebuilt image boots healthy and the full webhook → diagnosis demo works end-to-end. Co-authored-by: Claude Opus 4.8 (1M context) <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.
Closes #73.
The Dockerfile was the single-stage editable-install skeleton (it said so in its own header) with no
HEALTHCHECK, while the project status table marked the production image "Landed." This makes the claim true.What changed
pip install .into an isolated/opt/venvand pre-downloads the fastembed model; the slim runtime copies only/opt/venv+ the model cache (no build tooling, no source tree leaks), runs as the non-rootsentineluser, and bakes aHEALTHCHECKhitting/healthz(liveness —/readyzdepends on Postgres/Redis/Kafka and would wedge the container as unhealthy before deps connect).site-packages, which silently broke the per-env YAML loader:Path(__file__).resolve().parents[2]/"config"resolved tosite-packages/config/instead of the COPY'd/app/config. Added aSENTINEL_CONFIG_DIRoverride (defaults to the in-tree path for local/dev/test) and set it in the image.tests/unit/test_dockerfile.pyis a contract test guarding the structural claims (multistage,COPY --from,HEALTHCHECK, non-root, no editable install).test_config_dir_env_overrideguards the config-dir resolution regression.Verification (local, since CI can't build the image)
docker buildsucceeds; runs assentinel;from sentinel.api.app import build_app; build_app()imports clean (non-editable install + all deps);curlpresent;/opt/fastembedcache present (1.3G);HEALTHCHECKin image metadata; no/buildleakage.load_settings()resolves config inside the container (was a silent no-op before the fix).Review follow-ups (deliberately out of scope)
load_settings()would be stronger than the unit-level contract test, but adds a slow (~60s model download) job to every PR. Tracked thought, not done here.🤖 Generated with Claude Code