Add env_file support for Keycloak auth in docker-compose dev #165
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "164-dev-keycloak-auth"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
env_file: .envinto docker-compose web service.env.exampleto.envand fill in the client secret to enable auth.envfile, the app continues with graceful degradation (no auth required)Changes
docker-compose.yml: addedenv_file: .envto web service above ports/environment.env.example: new file with Keycloak connection vars and documentation comments.gitignore: added!/.env.exampleexception so the example file is tracked while real.envremains ignoredTest Plan
docker compose upwithout.envfile — app starts normally, no auth required.env.exampleto.env, fill in real secret,docker compose up— app redirects to Keycloak login.envis not tracked by git (git statusshows clean)Review Checklist
.envfile.Related Notes
ldraney/landscaping-assistant #164— the Forgejo issue this PR implementslandscaping-assistant— the project this work belongs toCloses #164
QA Review — PR #165
Scope: 3 files changed, +10/-1. Infrastructure wiring for Keycloak env vars in docker-compose dev.
Findings
[BLOCKING]
env_file: .envwill error when.envdoes not existDocker Compose v2 treats a missing
env_fileas a fatal error by default. Since the stated goal is graceful degradation (no.env= no auth, app still runs), this will break the default dev experience for anyone who hasn't copied.env.exampleto.env.Fix: use the optional file syntax:
This tells Compose to load
.envif present, skip silently if absent.[OK]
.gitignorechange — Correct pattern:/.env*excludes secrets,!/.env.exampleallows the template to be tracked.[OK]
.env.example— No real secrets, clear documentation comments, correct variable names matching the Keycloak config.[OK] PR body — Has all required sections,
Closes #164, feature flag consideration documented.Summary
One blocking issue: the
env_filedirective needsrequired: falseto achieve the stated graceful degradation behavior. Without it,docker compose upfails for developers who haven't created.env.VERDICT: REQUEST_CHANGES
Fixed in
e30a284:env_filenow usespath: .envwithrequired: falseso Compose skips silently when.envis absent. Ready for re-review.PR #165 Review
DOMAIN REVIEW
Tech stack: Docker Compose, Rails OmniAuth, gitignore patterns.
env_file correctness (Compose Spec v2.20+):
The
path: .envwithrequired: falseis the correct Compose Spec syntax for optional env files. When.envis absent, compose silently skips it -- no startup error. Confirmed working behavior.OmniAuth integration completeness:
The initializer at
config/initializers/omniauth.rb(lines 11-14) guards on exactly four vars:The
.env.exampleprovides all four. No missing vars.Graceful degradation (edge cases):
.envabsent: compose skips it, no KEYCLOAK vars set,keycloak_configuredis false, app runs without auth. SAFE..envexists but empty: same result -- all.present?checks fail, no auth loaded. SAFE..envwith partial vars (e.g., URL set but no secret):keycloak_configuredstill false due to&&chain. No partial-config crash. SAFE.Gitignore pattern:
/.env*ignores all root-level.env*files.!/.env.examplenegates the ignore for that specific file. Negation patterns work correctly when placed AFTER the ignore rule. Confirmed correct.Security:
.env.examplecontains only placeholder values (<get from k8s secret or Lucas>) -- no real secrets..envremains gitignored by/.env*rule.keycloak.tail5b443a.ts.net) is a Tailscale internal hostname -- not publicly reachable, acceptable to commit.BLOCKERS
None.
NITS
None. This is a clean, minimal change that does exactly what it should.
SOP COMPLIANCE
164-dev-keycloak-authmatches issue #164).env.examplehas placeholder only)PROCESS OBSERVATIONS
Small, focused infrastructure change with clear opt-in behavior. The graceful degradation pattern (presence of
.envenables auth, absence disables it) is a good developer experience -- no env var juggling needed.VERDICT: APPROVED