149 lines
4.9 KiB
YAML
149 lines
4.9 KiB
YAML
# Self-hosted personal finance stack
|
|
# traefik -> reverse proxy + TLS, forward-auth to authentik
|
|
# authentik -> SSO / login (server + worker + postgres; no Redis needed since 2025.10)
|
|
# finance -> the app (FastAPI) + its own postgres
|
|
#
|
|
# Usage: cp .env.example .env && edit && docker compose up -d --build
|
|
|
|
name: finance
|
|
|
|
x-authentik-env: &authentik-env
|
|
AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY:?set AUTHENTIK_SECRET_KEY in .env}
|
|
AUTHENTIK_ERROR_REPORTING__ENABLED: "false"
|
|
AUTHENTIK_POSTGRESQL__HOST: authentik-db
|
|
AUTHENTIK_POSTGRESQL__USER: authentik
|
|
AUTHENTIK_POSTGRESQL__NAME: authentik
|
|
AUTHENTIK_POSTGRESQL__PASSWORD: ${AUTHENTIK_DB_PASSWORD:?set AUTHENTIK_DB_PASSWORD in .env}
|
|
|
|
services:
|
|
traefik:
|
|
image: traefik:${TRAEFIK_TAG:-v3.6}
|
|
restart: unless-stopped
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
environment:
|
|
# Only needed if you use the Let's Encrypt DNS challenge (see traefik/traefik.yml)
|
|
CF_DNS_API_TOKEN: ${CF_DNS_API_TOKEN:-}
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
- ./traefik/traefik.yml:/etc/traefik/traefik.yml:ro
|
|
- ./traefik/dynamic:/etc/traefik/dynamic:ro
|
|
- ./traefik/certs:/certs:ro
|
|
- traefik-acme:/acme
|
|
networks: [proxy]
|
|
|
|
authentik-db:
|
|
image: postgres:16-alpine
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_USER: authentik
|
|
POSTGRES_DB: authentik
|
|
POSTGRES_PASSWORD: ${AUTHENTIK_DB_PASSWORD}
|
|
volumes:
|
|
- authentik-db:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -d authentik -U authentik"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks: [authentik]
|
|
|
|
authentik-server:
|
|
image: ghcr.io/goauthentik/server:${AUTHENTIK_TAG:-2026.8.5}
|
|
restart: unless-stopped
|
|
command: server
|
|
environment: *authentik-env
|
|
volumes:
|
|
- ./authentik/data:/data
|
|
- ./authentik/custom-templates:/templates
|
|
depends_on:
|
|
authentik-db:
|
|
condition: service_healthy
|
|
networks: [proxy, authentik]
|
|
labels:
|
|
- traefik.enable=true
|
|
- traefik.docker.network=finance_proxy
|
|
- traefik.http.routers.authentik.rule=Host(`${AUTH_HOST}`)
|
|
- traefik.http.routers.authentik.entrypoints=websecure
|
|
- traefik.http.routers.authentik.tls=true
|
|
- traefik.http.services.authentik.loadbalancer.server.port=9000
|
|
|
|
authentik-worker:
|
|
image: ghcr.io/goauthentik/server:${AUTHENTIK_TAG:-2026.8.5}
|
|
restart: unless-stopped
|
|
command: worker
|
|
user: root
|
|
environment: *authentik-env
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
- ./authentik/data:/data
|
|
- ./authentik/certs:/certs
|
|
- ./authentik/custom-templates:/templates
|
|
depends_on:
|
|
authentik-db:
|
|
condition: service_healthy
|
|
networks: [authentik]
|
|
|
|
finance-db:
|
|
image: postgres:16-alpine
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_USER: finance
|
|
POSTGRES_DB: finance
|
|
POSTGRES_PASSWORD: ${FINANCE_DB_PASSWORD:?set FINANCE_DB_PASSWORD in .env}
|
|
volumes:
|
|
- finance-db:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -d finance -U finance"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks: [finance]
|
|
|
|
finance:
|
|
build: ./app
|
|
restart: unless-stopped
|
|
environment:
|
|
DATABASE_URL: postgresql+psycopg://finance:${FINANCE_DB_PASSWORD}@finance-db:5432/finance
|
|
TZ: ${TZ:-Europe/Amsterdam}
|
|
PUBLIC_URL: https://${FINANCE_HOST}
|
|
# Enable Banking (optional, see README)
|
|
EB_APP_ID: ${EB_APP_ID:-}
|
|
EB_KEY_PATH: /run/secrets/enablebanking.pem
|
|
EB_SYNC_HOURS: ${EB_SYNC_HOURS:-6}
|
|
# Prices
|
|
COINGECKO_API_KEY: ${COINGECKO_API_KEY:-}
|
|
PRICE_REFRESH_MINUTES: ${PRICE_REFRESH_MINUTES:-60}
|
|
volumes:
|
|
- ./secrets:/run/secrets:ro
|
|
depends_on:
|
|
finance-db:
|
|
condition: service_healthy
|
|
networks: [proxy, finance]
|
|
labels:
|
|
- traefik.enable=true
|
|
- traefik.docker.network=finance_proxy
|
|
# The app itself, protected by authentik forward-auth
|
|
- traefik.http.routers.finance.rule=Host(`${FINANCE_HOST}`)
|
|
- traefik.http.routers.finance.entrypoints=websecure
|
|
- traefik.http.routers.finance.tls=true
|
|
- traefik.http.routers.finance.middlewares=authentik@file,secure-headers@file
|
|
- traefik.http.services.finance.loadbalancer.server.port=8000
|
|
# authentik's embedded outpost must answer /outpost.goauthentik.io/ on the app's host
|
|
- traefik.http.routers.finance-outpost.rule=Host(`${FINANCE_HOST}`) && PathPrefix(`/outpost.goauthentik.io/`)
|
|
- traefik.http.routers.finance-outpost.entrypoints=websecure
|
|
- traefik.http.routers.finance-outpost.tls=true
|
|
- traefik.http.routers.finance-outpost.priority=100
|
|
- traefik.http.routers.finance-outpost.service=authentik@docker
|
|
|
|
networks:
|
|
proxy:
|
|
authentik:
|
|
finance:
|
|
|
|
volumes:
|
|
traefik-acme:
|
|
authentik-db:
|
|
finance-db:
|