mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-09-21 13:28:57 +00:00
109 lines
3.5 KiB
YAML
109 lines
3.5 KiB
YAML
services:
|
|
|
|
proxy:
|
|
image: traefik:3.6
|
|
volumes:
|
|
# Add Docker as a mounted volume, so that Traefik can read the labels of other services
|
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
command:
|
|
# Enable Docker in Traefik, so that it reads labels from Docker services
|
|
- --providers.docker
|
|
# Do not expose all Docker services, only the ones explicitly exposed
|
|
- --providers.docker.exposedbydefault=false
|
|
# Create an entrypoint "http" listening on port 80
|
|
- --entrypoints.http.address=:80
|
|
# Enable the access log, with HTTP requests
|
|
- --accesslog
|
|
# Enable the Traefik log, for configurations and errors
|
|
- --log
|
|
|
|
db:
|
|
image: postgres:18
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
|
interval: 10s
|
|
retries: 5
|
|
start_period: 30s
|
|
timeout: 10s
|
|
volumes:
|
|
- app-db-data:/var/lib/postgresql
|
|
environment:
|
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?Variable not set}
|
|
- POSTGRES_USER=${POSTGRES_USER:?Variable not set}
|
|
- POSTGRES_DB=${POSTGRES_DB:?Variable not set}
|
|
|
|
adminer:
|
|
image: adminer
|
|
depends_on:
|
|
- db
|
|
environment:
|
|
- ADMINER_DESIGN=pepa-linha-dark
|
|
labels:
|
|
# Enable Traefik for this service
|
|
- traefik.enable=true
|
|
# Route HTTP traffic for the Adminer subdomain
|
|
- traefik.http.routers.adminer-http.rule=Host(`adminer.${DOMAIN:-localhost}`)
|
|
- traefik.http.routers.adminer-http.entrypoints=http
|
|
# Define the port inside of the Docker service to use
|
|
- traefik.http.services.adminer.loadbalancer.server.port=8080
|
|
|
|
backend:
|
|
image: backend:latest
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
restart: true
|
|
prestart:
|
|
condition: service_completed_successfully
|
|
# The YAML anchor lets the prestart service reuse this environment mapping.
|
|
environment: &backend-environment
|
|
PROJECT_NAME: ${PROJECT_NAME:?Variable not set}
|
|
BACKEND_CORS_ORIGINS: ${BACKEND_CORS_ORIGINS:-}
|
|
SECRET_KEY: ${SECRET_KEY:?Variable not set}
|
|
FIRST_SUPERUSER: ${FIRST_SUPERUSER:?Variable not set}
|
|
FIRST_SUPERUSER_PASSWORD: ${FIRST_SUPERUSER_PASSWORD:?Variable not set}
|
|
SMTP_HOST: ${SMTP_HOST}
|
|
SMTP_USER: ${SMTP_USER:-}
|
|
SMTP_PASSWORD: ${SMTP_PASSWORD:-}
|
|
EMAILS_FROM_EMAIL: ${EMAILS_FROM_EMAIL}
|
|
POSTGRES_SERVER: db
|
|
POSTGRES_DB: ${POSTGRES_DB:?Variable not set}
|
|
POSTGRES_USER: ${POSTGRES_USER:?Variable not set}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Variable not set}
|
|
SENTRY_DSN: ${SENTRY_DSN:-}
|
|
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/utils/health-check/"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
build:
|
|
context: .
|
|
dockerfile: backend/Dockerfile
|
|
labels:
|
|
# Enable Traefik for this service
|
|
- traefik.enable=true
|
|
|
|
# Define the port inside of the Docker service to use
|
|
- traefik.http.services.backend.loadbalancer.server.port=8000
|
|
|
|
# Route HTTP traffic for this domain
|
|
- traefik.http.routers.backend-http.rule=Host(`${DOMAIN:-localhost}`)
|
|
- traefik.http.routers.backend-http.entrypoints=http
|
|
|
|
prestart:
|
|
image: backend:latest
|
|
build:
|
|
context: .
|
|
dockerfile: backend/Dockerfile
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
restart: true
|
|
command: bash scripts/prestart.sh
|
|
environment: *backend-environment
|
|
|
|
volumes:
|
|
app-db-data:
|