docker compose: a shared .env can silently override your image ENV paths
Setup: a repo whose root .env serves both local (non-Docker) runs and docker compose (via env_file: .env). The local .env has DATABASE_URL=sqlite:///./data/blanc.db, and the backend image sets ENV DATABASE_URL=sqlite:////data/blanc.db to point at a mounted volume.
Gotcha: env_file values override the image ENV. The container would write the database to ./data inside the image filesystem instead of the volume, so it is lost on recreate, with no error.
Fix: in the service, put the container-only paths under environment: (DATABASE_URL, CASES_DIR, CORS_ORIGINS, and blank EVIDENCE_ROOT). In compose precedence, environment beats env_file, which beats the image ENV. Keep env_file for secrets only (API key, auth secret).
Related: - Use env_file with path: .env and required: false (compose 2.24+), so a fresh clone without .env still starts. - Bind ports to 127.0.0.1:PORT:PORT for a laptop app, so the LAN cannot reach it. - For a frontend that imports files from sibling folders (shared schemas), build from the repo root with dockerfile: frontend/Dockerfile and a root .dockerignore that excludes .env, *.db and node_modules.