mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-09-23 14:13:06 +00:00
134 lines
4.3 KiB
YAML
134 lines
4.3 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
|
|
env_file:
|
|
- .env
|
|
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?Variable not set}`)
|
|
- 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
|
|
|
|
prestart:
|
|
image: '${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}'
|
|
build:
|
|
context: .
|
|
dockerfile: backend/Dockerfile
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
restart: true
|
|
command: bash scripts/prestart.sh
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
- DOMAIN=${DOMAIN}
|
|
- FRONTEND_HOST=${FRONTEND_HOST?Variable not set}
|
|
- ENVIRONMENT=${ENVIRONMENT}
|
|
- 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_PORT=${POSTGRES_PORT}
|
|
- POSTGRES_DB=${POSTGRES_DB}
|
|
- POSTGRES_USER=${POSTGRES_USER?Variable not set}
|
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}
|
|
- SENTRY_DSN=${SENTRY_DSN}
|
|
|
|
backend:
|
|
image: '${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}'
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
restart: true
|
|
prestart:
|
|
condition: service_completed_successfully
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
- DOMAIN=${DOMAIN}
|
|
- FRONTEND_HOST=${FRONTEND_HOST?Variable not set}
|
|
- ENVIRONMENT=${ENVIRONMENT}
|
|
- 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_PORT=${POSTGRES_PORT}
|
|
- POSTGRES_DB=${POSTGRES_DB}
|
|
- 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?Variable not set}`)
|
|
- traefik.http.routers.backend-http.entrypoints=http
|
|
|
|
volumes:
|
|
app-db-data:
|