mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-02 13:15:17 +09:00
Single-container apps already get the effective env via docker run -e. Compose apps get container env from the compose file's environment:, so this wires them the same way through a managed override compose file. ComposeEnvService.refresh_for_project writes docker-compose.serverkit.yml next to a managed app's base compose, adding an environment: overlay to every service built from EnvService.get_effective_env (shared variable groups under the app's own local env vars). Compose merges the override on top of the base, so the effective env wins on collisions — consistent with the docker-run path. Dollar signs are escaped ($ -> $$) so values survive compose interpolation intact. DockerService.compose_up now includes the override as a second -f (via _compose_cmd_with_overlay); `up -d` recreates changed containers so updated env takes effect on the next deploy. It's non-destructive (ServerKit only owns the override; the base compose is never edited), best-effort/guarded (a build failure falls back to the plain base command and never blocks a deploy), regenerated each up, and removed when the app has no effective env. Non-app dirs (e.g. proxy stacks) and env-less apps are left untouched. Proving test test_compose_env_overlay.py (6 cases): overlay injects shared+local into every service with local winning collisions, $ escaping, stale-override cleanup, non-app dirs untouched, and compose_up running with -f base -f override. Full backend suite: 947 passed, 14 skipped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>