fix(local-dev): docker-compose + .env.example cover the new required env vars (closes #334)#335
Conversation
…env vars (closes #334) A fresh `docker-compose up -d` on this branch fails on startup because the compose file is missing several env vars the app now requires. This commit adds them with local-dev defaults and documents the same contract in `.env.example` so anyone running outside docker-compose (e.g. directly via Air or `go run ./cmd/server`) has a one-stop reference. Failure chain that this fixes (each gated the next): 1. scheduled-task auth init: SCHEDULED_TASK_AUTH_MODE unset 2. admin password resolution: ADMIN_PASSWORD_SECRET required 3. (after #333 lands) SECRET_PROVIDER=aws + empty AWS creds was working by luck; switching to `env` is now the correct local-dev resolver path 4. frontend admin-setup modal asks for an API key (sourced from API_KEY_SECRET_ARN → fails when the var is empty) `docker-compose.yml` (`app` service environment block): - SECRET_PROVIDER: aws → env (internal/secrets.EnvResolver, per internal/secrets/resolver.go:50 — pairs with EMAIL_ENABLED=false so the no-op email sender from #333 kicks in). - SCHEDULED_TASK_AUTH_MODE: disabled (internal/server/scheduledauth has no default and refuses to start when unset). - ADMIN_PASSWORD_SECRET / API_KEY_SECRET_ARN as VAR-NAME indirections pointing at ADMIN_PASSWORD_DEV / ADMIN_API_KEY_DEV (the EnvResolver pattern). Concrete dev values for both, plus ADMIN_EMAIL. - CREDENTIAL_ENCRYPTION_ALLOW_DEV_KEY=1 (gate the all-zero dev key per credentials.LoadKey — refuses to start without it). `.env.example` documents: - the new SECRET_PROVIDER=env contract (replaces the now-stale "env will fail" warning that pre-dated #333), - SCHEDULED_TASK_AUTH_MODE and EMAIL_ENABLED with one-line rationale, - the VAR-NAME-indirection pattern for *_SECRET / *_SECRET_ARN with the concrete dev values co-located so future readers can trace the chain in one file. Depends on PR #333 (no-op email sender) — without that, the email factory crashes on SECRET_PROVIDER=env. Sequencing intentional. Verification: - docker-compose up -d brings postgres + app + frontend to healthy - curl http://localhost:8080/api/health → HTTP 200 - admin-setup modal accepts the documented dev defaults
|
@coderabbitai review |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughConfiguration templates and docker-compose service environment updated for local development: ChangesLocal Development Environment Configuration
🎯 2 (Simple) | ⏱️ ~10 minutes Possibly Related PRs
Suggested Labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.env.example:
- Around line 61-71: Update the ADMIN_EMAIL default in the .env.example to match
the local-dev value used in docker-compose (change ADMIN_EMAIL from
admin@example.com to admin@cudly.local) so the template and docker-compose
defaults are consistent; modify the ADMIN_EMAIL entry in the file (look for the
ADMIN_EMAIL variable near ADMIN_PASSWORD_SECRET / ADMIN_PASSWORD_DEV) to the new
address.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bab7b6ac-0481-4b9d-aac7-0f67650fca4e
📒 Files selected for processing (2)
.env.exampledocker-compose.yml
…fault (CR pass on PR #335) CodeRabbit nitpick on PR #335: `.env.example` still listed `ADMIN_EMAIL=admin@example.com` while `docker-compose.yml` defaults to `admin@cudly.local`. The drift made the two reference points disagree about which placeholder a fresh checkout should use. Aligning on `admin@cudly.local` keeps both files telling the same story.
|
Addressed CR's actionable in commit b7a5f6d: |
|
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
PR #333 (closes #332) landed a botched merge of `unset_falls_through` in TestNewSenderFromEnvironment_EmailEnabled — two overlapping copies of the same sub-test ended up concatenated (one missing its closing braces, one preceded by stray fragments), plus duplicate `ctx :=` / `sender, err :=` lines. The result didn't parse: gofmt -l internal/email/factory_test.go internal/email/factory_test.go:309:2: missing ',' before newline ... internal/email/factory_test.go:312:6: expected '(', found TestNewSenderWithConfig_AWS This trips `gofmt` and `go vet` in the pre-commit workflow on every open PR against `feat/multicloud-web-frontend` (e.g. #326, #335, #336). Keep the `prev/hadPrev` version of the sub-test (the one that actually does `os.Unsetenv` first, which is the case the test name describes), drop the orphaned `orig/hadOrig` fragment, and remove the duplicate ctx/sender declarations. Verified locally: gofmt clean, `go vet ./internal/email/...` clean, `go test ./internal/email/...` 306 tests pass.
Summary
A fresh
docker-compose up -don this branch crashes on startup becausethe compose file is missing several env vars the app now requires.
This PR adds them with local-dev defaults and documents the same
contract in
.env.exampleso anyone running outside compose has aone-stop reference.
Failure chain this fixes
Without this PR, a fresh
docker-compose up -dhits these one by one:scheduled-task auth init: SCHEDULED_TASK_AUTH_MODE is unset—internal/server/scheduledauth/config.gorequires explicit choice.ADMIN_PASSWORD_SECRET environment variable is required but not set; refusing to start without a Secrets Manager ARN.SECRET_PROVIDER=aws+ empty AWS creds wasworking by luck; switching to
envis the correct local-dev path.API_KEY_SECRET_ARN→ fails when empty).Changes
docker-compose.yml(appservice environment block):SECRET_PROVIDER: env(wasaws) — pairs withEMAIL_ENABLED=falseso the no-op email sender from fix(email): short-circuit to no-op sender when EMAIL_ENABLED=false (closes #332) #333 kicks in.
SCHEDULED_TASK_AUTH_MODE: disabled.ADMIN_PASSWORD_SECRET/API_KEY_SECRET_ARNas VAR-NAMEindirections pointing at concrete dev values
(
ADMIN_PASSWORD_DEV/ADMIN_API_KEY_DEV).ADMIN_EMAIL: admin@cudly.local.CREDENTIAL_ENCRYPTION_ALLOW_DEV_KEY: "1"..env.example:SECRET_PROVIDERblock to remove the now-stale "env willfail" warning and explain the new contract.
SCHEDULED_TASK_AUTH_MODEsection.EMAIL_ENABLEDsection with cross-reference to fix(email): short-circuit to no-op sender when EMAIL_ENABLED=false (closes #332) #333.*_SECRET/*_SECRET_ARNwith concrete dev values co-located so future readers can trace the
chain in one file. Kept the AWS-ARN production examples as
commented-out alternatives.
Dependency
Depends on #333 (no-op email sender). Without that, the email
factory crashes on
SECRET_PROVIDER=env. Sequencing intentional —this PR is a no-op until #333 merges.
Closes #334.
Test plan
docker compose up -d postgres app frontendbrings the stack tohealthy on a fresh checkout.
curl http://localhost:8080/api/health→ HTTP 200.index.html.(API key
cudly-local-dev-api-key-not-for-prod,email
admin@cudly.local,password
LocalDev!Pass123).the cloud secret resolver handles them).
Summary by CodeRabbit