ai-coding-minesIndexGitHub

A file the runtime reads isn't in the image

Deploy and infrastructure

Symptom

Local and CI unit tests all green (the file exists in the repo), but only in the deployed build: 404 / 400 / file not found. Same type, three recurrences.

Cause pattern

A route reads a relative path (Path("data/x.json")) and that file isn't in the image. Two root causes, sometimes both:

  1. The Dockerfile doesn't COPY that directory
  2. .dockerignore excludes the whole directory, so it is gone before the build context even forms

Fix

Habit

Whenever you add or move a path the runtime reads, three-way check: (1) Dockerfile COPY (2) .dockerignore exclusions (3) the route's relative path vs WORKDIR

Verification trick (when you can't pull the base image)

.dockerignore has nothing to do with the base image. Build the same COPY lines FROM scratch and context inclusion is verified as-is: if excluded, it fails with "not found in build context."

Inspecting a shell-less scratch image directly

FROM scratch has no shell, so docker run … ls is not an option. Extract without running: docker create <img> /xdocker cp <cid>:/app/data ./outls -la ./out, then compare sha256 against the source in the repo. Same bytes or it didn't land.