Archive user-profile change to openspec/changes/archive/ All tasks complete, specs already synced to main specs directory.
3.6 KiB
Context
The current docker-compose.yml is a standalone development setup without reverse proxy support. The API has hardcoded Authentik URLs in config.py (https://authentik.local/...) which makes it impossible to deploy in real environments without code changes. The frontend also hardcodes VITE_API_URL=http://localhost:8000.
For production deployment, the platform needs to work behind an existing Traefik reverse proxy (common in self-hosted stacks) and have all external service endpoints fully configurable.
Goals / Non-Goals
Goals:
- Make all Authentik URLs configurable via environment variables (no hardcoded defaults).
- Make OAuth redirect/callback URLs configurable and domain-aware.
- Create
docker-compose.traefik.ymlfor deployment behind an existing Traefik instance. - Support configuring the public web domain, API domain, and Authentik domain via env vars.
- Ensure both development (
docker-compose.yml) and traefik modes work correctly.
Non-Goals:
- Setting up Traefik itself (assumes existing Traefik instance).
- Authentik installation/configuration (assumes existing Authentik instance).
- SSL certificate management (handled by Traefik).
- Changing the authentication flow or token logic.
Decisions
-
Remove all hardcoded URLs from
config.pyand require env vars- Rationale: Deployment environments have different domains. Hardcoded values are a deployment blocker.
- Alternative: Keep defaults and override in prod. Rejected because defaults mask configuration errors.
-
Use
API_DOMAINandWEB_DOMAINenv vars for constructing public URLs- Rationale: Centralizes domain configuration and makes it easy to switch between dev/prod.
API_PUBLIC_URLwill default tohttp://${API_DOMAIN}or can be overridden.WEB_PUBLIC_URLwill default tohttp://${WEB_DOMAIN}or can be overridden.
-
Create a separate
docker-compose.traefik.ymlinstead of modifying the existing one- Rationale: The existing
docker-compose.ymlis for standalone development. Traefik deployment is a different topology. - Alternative: Use compose profiles or overrides. Rejected to keep each file simple and explicit.
- Rationale: The existing
-
Add
VITE_APP_URLfor the frontend so it knows its public URL- Rationale: OAuth redirect URI needs to be absolute and must match the public web URL.
- Frontend will use this for login redirect if needed.
-
Use Traefik labels for routing instead of ports
- Rationale: Standard Traefik pattern - services are discovered via Docker labels.
- No port mappings exposed; Traefik handles all ingress.
Risks / Trade-offs
- [Missing env vars cause startup failures] -> Document all required variables in
.env.exampleand add validation in config.py. - [OAuth redirect URI mismatch] -> Ensure the redirect URI configured in Authentik matches the env-configured callback URL exactly.
- [Local development still works] -> Keep
docker-compose.ymlunchanged for dev; traefik file is additive. - [Cookie secure flag] -> Ensure
cookie_secureproperty in config reads from env properly for HTTPS deployments.
Migration Plan
- Update
config.pyto read all Authentik URLs from environment with no defaults. - Update
auth.pyto construct redirect/callback URLs from env-configured domains. - Update
.env.examplewith all new variables. - Create
docker-compose.traefik.ymlwith Traefik labels. - Test that both
docker-compose.yml(dev) anddocker-compose.traefik.yml(prod) work.
Rollback:
- Revert config.py and auth.py changes; remove
docker-compose.traefik.yml.
Open Questions
- Should we add a startup health check that validates all required env vars are set?