When Compose injects Node env, treat environment: as the deploy-time override layer and keep secrets out of image ENV and out of committed env_file. Order matters: a Dockerfile ENV that looks fine locally still loses to environment: at runtime, while an env_file that is only mounted in one service leaves sibling containers with undefined process.env keys. Prefer a short allow-list of non-secret config in Compose, inject secrets from the orchestrator or a runtime secret mount, and fail fast at boot if required keys are missing rather than discovering undefined halfway through a request.
Ops check after a compose config change: print the effective env inside the Node container for the keys you care about (without dumping secrets into logs), hit a readiness path that asserts those keys parsed, then restart only that service and compare. A sudden undefined after a rebuild usually means the wrong file was referenced, a key was renamed in one layer but not another, or the process still runs an old container that never received the new environment: block.