|
| 1 | +services: |
| 2 | + dev: |
| 3 | + build: |
| 4 | + context: .. |
| 5 | + dockerfile: .devcontainer/Dockerfile |
| 6 | + image: fastapi-modulith:dev |
| 7 | + restart: unless-stopped |
| 8 | + environment: |
| 9 | + APP_ENV: development |
| 10 | + DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-devpass}@db:5432/${POSTGRES_DB:-todo_db} |
| 11 | + REDIS_URL: redis://:${REDIS_PASSWORD:-devpass}@redis:6379/0 |
| 12 | + OTEL_ENABLED: "true" |
| 13 | + OTEL_SERVICE_NAME: "fastapi-modulith" |
| 14 | + OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4318/v1/traces" |
| 15 | + env_file: |
| 16 | + - ../.env |
| 17 | + volumes: |
| 18 | + - ..:/app:cached |
| 19 | + ports: |
| 20 | + - "${APP_PORT:-8000}:8000" |
| 21 | + depends_on: |
| 22 | + db: |
| 23 | + condition: service_healthy |
| 24 | + redis: |
| 25 | + condition: service_healthy |
| 26 | + command: sleep infinity |
| 27 | + |
| 28 | + prometheus: |
| 29 | + image: prom/prometheus:latest |
| 30 | + restart: unless-stopped |
| 31 | + ports: |
| 32 | + - "${PROMETHEUS_PORT:-9090}:9090" |
| 33 | + volumes: |
| 34 | + - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro |
| 35 | + - prometheus_data:/prometheus |
| 36 | + command: |
| 37 | + - "--config.file=/etc/prometheus/prometheus.yml" |
| 38 | + - "--storage.tsdb.path=/prometheus" |
| 39 | + - "--storage.tsdb.retention.time=30d" |
| 40 | + |
| 41 | + otel-collector: |
| 42 | + image: otel/opentelemetry-collector-contrib:latest |
| 43 | + restart: unless-stopped |
| 44 | + ports: |
| 45 | + - "${OTEL_COLLECTOR_PORT:-4318}:4318" |
| 46 | + volumes: |
| 47 | + - ../docker/otel-collector/config.yaml:/etc/otelcol-contrib/config.yaml:ro |
| 48 | + |
| 49 | + db: |
| 50 | + image: postgres:17-alpine |
| 51 | + restart: unless-stopped |
| 52 | + environment: |
| 53 | + POSTGRES_USER: ${POSTGRES_USER:-postgres} |
| 54 | + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-devpass} |
| 55 | + POSTGRES_DB: ${POSTGRES_DB:-todo_db} |
| 56 | + volumes: |
| 57 | + - postgres_data:/var/lib/postgresql/data |
| 58 | + healthcheck: |
| 59 | + test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] |
| 60 | + interval: 10s |
| 61 | + timeout: 5s |
| 62 | + retries: 5 |
| 63 | + |
| 64 | + redis: |
| 65 | + image: redis:8-alpine |
| 66 | + restart: unless-stopped |
| 67 | + command: |
| 68 | + [ |
| 69 | + "redis-server", |
| 70 | + "--appendonly", |
| 71 | + "yes", |
| 72 | + "--requirepass", |
| 73 | + "${REDIS_PASSWORD:-devpass}", |
| 74 | + ] |
| 75 | + volumes: |
| 76 | + - redis_data:/data |
| 77 | + healthcheck: |
| 78 | + test: |
| 79 | + [ |
| 80 | + "CMD", |
| 81 | + "redis-cli", |
| 82 | + "-a", |
| 83 | + "${REDIS_PASSWORD:-devpass}", |
| 84 | + "ping", |
| 85 | + ] |
| 86 | + interval: 10s |
| 87 | + timeout: 5s |
| 88 | + retries: 5 |
| 89 | + |
| 90 | +volumes: |
| 91 | + postgres_data: |
| 92 | + redis_data: |
| 93 | + prometheus_data: |
0 commit comments