Contain local-dev env state inside .devcontainer/#1
Merged
Conversation
Wire `.devcontainer/.env` into both Compose (auto-discovery) and the dev container itself (`runArgs --env-file`), with a host-side `initializeCommand` that creates the file from the template before `docker run` and strips CRLF for Windows/WSL. Adds Taskfile env:* commands, an env-check library + MOTD warnings for drift and unfilled required keys, and a lefthook pre-commit guard against accidentally staging the gitignored .env. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Quiet ShellCheck SC2001 ("use parameter expansion instead of sed")
without changing behavior. The awk form is also slightly cleaner.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.devcontainer/.envinto both Docker Compose (auto-discovery) and the dev container itself (runArgs --env-file), with a new host-sideinitializeCommandthat creates the file from the template beforedocker runand strips CRLF for Windows/WSL safety..env.examplewith section banners and a three-state grammar (filled defaults / required-empty / optional override), and document the convention.Taskfile.yml(env:check,env:required,env:diff,env:reset), anenv-check.shlibrary, MOTD warnings for drift or unfilled required keys, and alefthook.ymlpre-commit guard against accidentally committing.devcontainer/.env.Result:
rm -rf .devcontainer/.envfollowed by a container rebuild fully resets local-dev env state with no other files touched.Test plan
.devcontainer/.envis created on the host andecho $POSTGRES_USERinside the container returnspostgres..devcontainer/.envand rebuild; same outcome.FOO=barline to.env.exampleonly; reopen shell — MOTD shows yellowEnvironmentblock listingFOO;task env:checkexits non-zero.task env:resetand confirm yes;.envre-synced; MOTD warning clears..devcontainer/.envwith CRLF endings; rebuild; container still starts cleanly..devcontainer/.envand try to commit; lefthook rejects.Validateworkflow (ShellCheck, Compose Config, Env Template Sync, Devcontainer Build) all green.🤖 Generated with Claude Code