refactor(devcontainer): support local environment overrides - #433
Conversation
Move the tracked Dev Container build defaults from the repository-level .env file to .devcontainer/.env.defaults. Generate an ignored .env.compose during initializeCommand by copying the defaults and appending optional values from .env.local. Point .devcontainer/.env at the generated file so Compose discovers the merged configuration without requiring an extra setup command. Ignore root-level .env variants in Git and Docker build contexts, document dependency overrides and per-checkout Compose project names, and broaden the editor guidance to IDEs implementing the Development Container Specification.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b54e192188
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| checkout_name=$(basename -- "${repo_root}") | ||
|
|
||
| cp "${repo_root}/.devcontainer/.env.defaults" "${compose_env}" | ||
| printf '\nCOMPOSE_PROJECT_NAME=simphony-%s-%s\n' ${user_name} ${checkout_name} >> ${compose_env} |
There was a problem hiding this comment.
Quote the Compose environment redirection
When the checkout resides in a path containing whitespace, ${compose_env} expands into multiple redirection words, so Bash exits with ambiguous redirect under set -e before .env.compose is populated. This makes devcontainer up unable to initialize for such checkouts; quote the redirection target and the two printf arguments.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Refactors the Dev Container environment configuration to support per-checkout local overrides by moving tracked defaults into .devcontainer/.env.defaults and generating a merged Compose env file during initialization.
Changes:
- Move default dependency version settings into
.devcontainer/.env.defaultsand update docs accordingly. - Add an initialization script and hook it from
devcontainer.jsonto generate a merged env file. - Ignore root-level
.env.*variants in Git and Docker build contexts.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates guidance to reference .devcontainer/.env.defaults and local override flow. |
| docs/getting-started.md | Documents .env.local overrides, generated .env.compose, and project-name configuration. |
| .gitignore | Ignores root .env.* variants to prevent accidental commits of local env files. |
| .dockerignore | Excludes .env.* from Docker build context. |
| .devcontainer/initialize-compose-env.sh | New script to assemble merged Compose env configuration at init time. |
| .devcontainer/devcontainer.json | Runs the new init script via initializeCommand. |
| .devcontainer/.env.defaults | Adds the tracked default OS/toolchain version settings for Dev Container builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| compose_env="${repo_root}/.env.compose" | ||
| user_name=${USER:-$(id -un)} | ||
| checkout_name=$(basename -- "${repo_root}") | ||
|
|
||
| cp "${repo_root}/.devcontainer/.env.defaults" "${compose_env}" | ||
| printf '\nCOMPOSE_PROJECT_NAME=simphony-%s-%s\n' ${user_name} ${checkout_name} >> ${compose_env} | ||
| if [[ -f "${repo_root}/.env.local" ]]; then | ||
| printf '\n' >> "${compose_env}" | ||
| cat "${repo_root}/.env.local" >> "${compose_env}" | ||
| fi |
Move the tracked Dev Container build defaults from the repository-level .env file to .devcontainer/.env.defaults.
Generate an ignored .env.compose during initializeCommand by copying the defaults and appending optional values from .env.local. Point .devcontainer/.env at the generated file so Compose discovers the merged configuration without requiring an extra setup command.
Ignore root-level .env variants in Git and Docker build contexts, document dependency overrides and per-checkout Compose project names, and broaden the editor guidance to IDEs implementing the Development Container Specification.