Fix Docker Build: hatchling + README context (ar-r82f.13)#93
Merged
Conversation
The Docker Build CI job has been failing because the runtime stage of
infra/docker/Dockerfile installs the package with `pip install -e .` but
never copies README.md from the builder stage. pyproject.toml declares
`readme = "README.md"` so hatchling's metadata validation fails with:
OSError: Readme file does not exist: README.md
Root cause was misdiagnosed earlier as a hatchling backend issue. The
AttributeError on `hatchling.build.prepare_metadata_for_build_editable`
seen in the traceback is the normal pip pyproject_hooks fallback path
(hatchling exposes that hook as a function, not a module attribute); the
real failure is the readme OSError raised during metadata validation.
Changes:
- infra/docker/Dockerfile: copy README.md into the runtime stage so
`pip install -e .` succeeds.
- pyproject.toml: pin hatchling to >=1.21 to guarantee the build
backend version pip uses is recent (defensive; not the root cause).
Verified locally: `docker build -f infra/docker/Dockerfile .` now
succeeds and `docker run` produces a healthy uvicorn process responding
200 on /health, matching the CI Docker Build job's verification step.
bead: ar-r82f.13
Co-Authored-By: Claude Sonnet 4.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.
Summary
Fix the long-failing Docker Build CI job. The root cause is a missing
README.mdin the runtime stage ofinfra/docker/Dockerfile—pip install -e .invokes hatchling's metadata validator, which reads the path declared byreadme = "README.md"inpyproject.tomland raisesOSError: Readme file does not exist: README.md.Root Causes
README missing in runtime stage (the actual failure). Stage 2 (
runtime) copiessrc/andpyproject.tomlfrom the builder but never copiesREADME.md. The subsequentRUN pip install --no-cache-dir -e .then fails withOSError: Readme file does not exist: README.md.Hatchling
prepare_metadata_for_build_editable(red herring). The traceback showsAttributeError: module 'hatchling.build' has no attribute 'prepare_metadata_for_build_editable', but this is the normal pip pyproject_hooks fallback path on modern hatchling (the hook is exposed as a function, not a module attribute) and is followed by the realOSErrorraised during metadata validation. A defensive pin (hatchling>=1.21) is added inpyproject.tomlso nothing older can be picked up.Changes
infra/docker/Dockerfile: addCOPY --from=builder /build/README.md ./in the runtime stage so the editable install can read it.pyproject.toml: pinrequires = ["hatchling>=1.21"]in[build-system](defensive).Before / After (local
docker build -f infra/docker/Dockerfile -t ad-buyer-system:test .)Before:
After:
Container runs cleanly: uvicorn comes up, MCP server mounts,
GET /healthreturns200 OK(matches the CI Docker Build job'sVerify health check endpoint existsstep).Test plan
origin/main(90764ab) — confirmedOSError: Readme file does not exist: README.md.docker build -f infra/docker/Dockerfile -t ad-buyer-system:test .succeeds locally.docker run -d -p 8001:8001 ad-buyer-system:teststarts and/healthreturns 200.Docker Buildjob turns green.Testjob stays green (not touched by this PR;Lintfailure on main is pre-existing and out of scope).Out of scope
Lintjob is failing onmainfor an unrelated reason (ruff check onsrc//tests/). Not addressed here.infra/docker/.dockerignoreis present but unused at the current build-context root; leaving it alone to avoid scope creep.bead: ar-r82f.13