feat(compose): expose deployment context for interpolation#2189
Conversation
|
You're right — this was the missing path. The caller constructs the initial loader before The initial I also removed the questionable shadowing: the preliminary project result is explicitly discarded, and |
Bring this repo in line with DefangSamples/sample-self-improving-mastra-template
(the source this repo was generated from), which has since fixed the Fargate
health check and moved self-publish onto Defang's resolved deployment context.
- todo-app/Dockerfile: bind Next standalone to 0.0.0.0 so the `curl localhost`
container health check passes on Fargate (the runtime injects HOSTNAME and
would otherwise leave loopback unbound); exec keeps node as PID 1 for SIGTERM.
- compose.yaml / .env.{aws,gcp}: self-publish now reads ${DEFANG_PROVIDER} and
${DEFANG_STACK} from Defang's deployment context instead of PUBLISH_PROVIDER/
PUBLISH_STACK committed in the per-cloud env files.
- agent/src/publish.ts, README.md: match the deployment-context mechanism.
NOTE: the ${DEFANG_PROVIDER}/${DEFANG_STACK} support requires a Defang CLI that
includes DefangLabs/defang#2189; v3.12.0 does not have it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sw7j9FYnbChZJbYArxbhuo
Description
Make the resolved deployment context available to Compose interpolation after stack selection:
DEFANG_PROVIDER: the selected providerDEFANG_STACK: the selected stack nameThe values are opt-in and are not injected into service environments unless referenced explicitly. Selected context takes precedence over Compose env files, while arbitrary process
DEFANG_*variables remain filtered out.Agent/MCP deployments reload Compose after interactive stack/provider selection so they use the same resolved interpolation context as direct CLI deployments. The reload preserves relative working directories, custom Compose paths, project names, and missing-config retry behavior.
This enables samples such as self-improving-mastra to pass provider and stack metadata into the deployed service without requiring portal-supplied configuration.
The canonical README now documents the interpolation behavior and regenerates the CLI/npm README copies. Also includes a formatter-only alignment correction in
fixup.gorequired for the repository-wide lint gate.Linked Issues
N/A
Testing
go test -race -short ./...go vet ./...golangci-lint runmake -B src/README.mdChecklist