fix(build): build frontend image from repo root so backend type imports resolve

⛔ closed · #389 · open-legal-products/mike ← terpstra-209/mike · opened 8d ago by terpstra-209 · closed 3d ago · +24-4 across 3 files · ↗ on GitHub

From the PR description

Summary

docker-compose.yml built the frontend image with context: ./frontend, but frontend/src/app/components/shared/types.ts imports backend types through a relative path reaching outside the frontend package (../../../../../backend/src/lib/chat/types). With a ./frontend build context, backend/ doesn't exist in the image, so the import silently degrades to any and next build fails on the first place that surfaces as an implicit any:

./src/app/components/assistant/AskInputPopup.tsx:93:31
Type error: Parameter 'item' implicitly has an 'any' type.

Changes

  • docker-compose.yml - frontend service now builds with context: . and dockerfile: frontend/Dockerfile, so both packages sit side by side in the build.
  • frontend/Dockerfile - works from /app/frontend, copies frontend/ and backend/ into the image separately so the relative import resolves.
  • .dockerignore (new, tracked) - building from the repo root would otherwise ship node_modules, word-addin, and .git into the build context (537 MB in practice); this keeps it to just what's needed.

An alternative - annotating the one call site with an explicit type - only silences that one symptom; every other backend-imported type in the frontend would stay any, which is a bad trade in a tool handling privileged documents.

Testing

docker compose config -q          valid
docker compose up -d --build      frontend and backend build and start healthy

Verified end-to-end on a real local Docker Compose stack, not just config validation.

The investigation and code in this PR were done by Claude (Sonnet 5) via Claude Code; I reviewed and am submitting it.

Our analysis

Fix frontend Docker build context — read the full analysis →

Think the analysis missed something the PR description covers?

Capture this PR into my fork

Download a Markdown prompt that tells Claude how to port every commit in this PR into your working tree. Run it via claude -p < capture-pull-389.md from inside the repo you want the changes in.

⬇ Download capture-pull-389.md