Stop handing StackPilot's own settings to the stacks it deploys (0.66.3)
docker compose ran with StackPilot's whole environment, and compose
resolves ${VAR} from the calling environment before a stack's own .env.
A stack whose compose file says SECRET_KEY: ${SECRET_KEY} therefore ran
with StackPilot's SECRET_KEY instead of the one in its .env — and with
its own again whenever it was started from a shell. AnsiblePilot hit
exactly this: credentials saved under one key became unreadable under
the other, twice.
config.child_env() is os.environ minus every StackPilot setting
(SECRET_KEY, DATA_DIR, STACKS_DIR, PORT, ...); the docker CLI and git
subprocesses now get that instead.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
34458c702c
commit
052a85067b
7 files changed
+44
-7
No files matched your search
@@ -118,3 +118,18 @@ def get_settings() -> Settings:
|
||||
|
||||
|
||||
settings = get_settings()
|
||||
|
||||
|
||||
def child_env() -> dict[str, str]:
|
||||
"""os.environ without StackPilot's own settings, for docker/git subprocesses.
|
||||
|
||||
Compose resolves ``${VAR}`` from the calling environment *before* the
|
||||
stack's own ``.env``, so everything StackPilot was configured with leaked
|
||||
into every stack it deployed. A stack whose compose file says
|
||||
``SECRET_KEY: ${SECRET_KEY}`` silently ran with StackPilot's key instead of
|
||||
its own — and flipped back whenever it was started from a shell, orphaning
|
||||
whatever it had encrypted in between. Names like SECRET_KEY, PORT or
|
||||
DATA_DIR are far too common to share.
|
||||
"""
|
||||
own = {name.upper() for name in Settings.model_fields}
|
||||
return {k: v for k, v in os.environ.items() if k.upper() not in own}
|
||||
Reference in new issue
Block a user