Skip to content

🐳 Fix docker compose runtime blockers on clean clone - #4

Merged
GiorgosPanagopoulos merged 1 commit into
mainfrom
fix/docker-runtime-blockers
Aug 10, 2026
Merged

🐳 Fix docker compose runtime blockers on clean clone#4
GiorgosPanagopoulos merged 1 commit into
mainfrom
fix/docker-runtime-blockers

Conversation

@GiorgosPanagopoulos

Copy link
Copy Markdown
Owner

Summary

docker compose up did not work on a clean clone. Seven separate blockers, fixed together since they compound (fixing one just exposes the next):

  1. Missing env_file in composebackend service had no env_file, and the environment: block substituted ${ANTHROPIC_API_KEY}/${OPENAI_API_KEY} from the (unset) host shell as empty strings, shadowing backend/.env and tripping the must_not_be_empty validator in config.py before the app could start.
  2. No automatic seedingbackend/data/seed.py was a standalone script; a clean docker compose up landed on an empty database. Refactored into an idempotent seed_if_empty(db) (returns early if suppliers is non-empty) and called it from the FastAPI lifespan.
  3. Superuser seed race — the get_user_by_emailcreate_user sequence raised DuplicateKeyError on repeated or concurrent boots against the unique {email:1} index. Replaced with a single atomic update_one({...}, {"$setOnInsert": {...}}, upsert=True).
  4. LANGCHAIN_TRACING_V2=false in backend/.env.example (was true with no API key set, which is a broken default).
  5. README seed command corrected — Quick Start referenced python backend/data/seed.py (wrong path, ModuleNotFoundError). Now states sample data is seeded automatically on first startup, with the correct manual re-seed command (cd backend && PYTHONPATH=. python data/seed.py).
  6. Dockerfile.backend PATH fixpip install --target places console scripts (including uvicorn) under site-packages/bin, which was never added to PATH in the final image. The backend container failed to start on every clean build with exec: "uvicorn": executable file not found in $PATH. Found this while verifying the other five fixes end-to-end — without it docker compose up still didn't work.
  7. Added .dockerignore — none existed, so every build sent the full repo (.git, node_modules, chroma_db, etc.) as build context. Confirmed 104MB and still climbing after 11+ minutes on a real npm install'd checkout, never finishing.

Also migrated the remaining Pydantic v2 .dict() calls in seed.py to .model_dump().

Verification

  • docker compose config | grep -i anthropic — key resolves from backend/.env, never appears empty
  • docker compose up --build — all three containers (backend, frontend, mongo) start cleanly
  • curl localhost:8000/suppliers (authenticated) — 12 suppliers, 16 bids seeded
  • docker compose restart backend — clean second boot: logs superuser_exists, no seed re-run, no crash
  • cd backend && pytest160 passed
  • Backend build/context transfer: 11+ minutes (104MB, still growing, never completed) before the .dockerignore fix → ~6 seconds after

Test plan

  • docker compose up --build succeeds on a clean clone
  • /suppliers returns 12 records after login
  • Second boot (docker compose restart backend) does not crash or re-seed
  • pytest — 160/160 passing

- Drop obsolete compose version key; load backend/.env via env_file and
  stop shadowing ANTHROPIC_API_KEY/OPENAI_API_KEY with empty host vars,
  which tripped the must_not_be_empty validator before the app started
- Seed MongoDB automatically from FastAPI lifespan via idempotent
  seed_if_empty(), so first boot always has sample data
- Replace the superuser get-then-create sequence with an atomic
  $setOnInsert upsert, fixing a DuplicateKeyError on repeated/concurrent
  boots
- Add a proper .dockerignore (.git, node_modules, chroma_db, etc.) and
  fix Dockerfile.backend PATH so pip --target console scripts
  (uvicorn) are actually runnable in the final image
- Disable LangSmith tracing by default in .env.example
- Update README quick start to reflect automatic seeding
- Migrate remaining Pydantic .dict() calls to .model_dump()
@GiorgosPanagopoulos
GiorgosPanagopoulos merged commit e669a4b into main Aug 10, 2026
2 checks passed
@GiorgosPanagopoulos
GiorgosPanagopoulos deleted the fix/docker-runtime-blockers branch August 10, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant