-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.yml
More file actions
87 lines (83 loc) · 2.55 KB
/
compose.yml
File metadata and controls
87 lines (83 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
services:
app:
build:
context: .
dockerfile: Dockerfile
container_name: fastapi-app
env_file:
- .env
ports:
- "8000:8000"
environment:
- APP_ENV=${APP_ENV:-development}
- APP_PORT=${APP_PORT:-8000}
- DB_HOSTNAME=postgres
- DB_PORT=5432
- DB_PASSWORD=${DB_PASSWORD:?DB_PASSWORD is required}
- DB_NAME=${DB_NAME:-fastapi}
- DB_USERNAME=${DB_USERNAME:-postgres}
- SECRET_KEY=${SECRET_KEY:?SECRET_KEY is required}
- ALGORITHM=${ALGORITHM:-HS256}
- ACCESS_TOKEN_EXPIRE_MINUTES=${ACCESS_TOKEN_EXPIRE_MINUTES:-60}
- OTEL_SERVICE_NAME=fastapi-postgres-app
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
- OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES:-deployment.environment=development,service.version=1.0.0}
- ALLOWED_ORIGINS=${ALLOWED_ORIGINS:-http://localhost:3000}
depends_on:
postgres:
condition: service_healthy
otel-collector:
condition: service_started
networks:
- app-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s
postgres:
image: postgres:18-alpine
container_name: fastapi-postgres
environment:
- POSTGRES_USER=${DB_USERNAME:-postgres}
- POSTGRES_PASSWORD=${DB_PASSWORD:?DB_PASSWORD is required}
- POSTGRES_DB=${DB_NAME:-fastapi}
ports:
- "5432:5432"
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d fastapi"]
interval: 5s
timeout: 5s
retries: 5
networks:
- app-network
otel-collector:
image: otel/opentelemetry-collector-contrib:0.147.0
container_name: otel-collector
volumes:
- ./config/otel-config.yaml:/etc/otelcol-contrib/config.yaml
ports:
- "4317:4317" # OTLP gRPC receiver
- "4318:4318" # OTLP HTTP receiver
- "55679:55679" # zpages extension
- "13133:13133" # health_check extension
env_file:
- path: .env
required: false
environment:
- SCOUT_ENDPOINT=${SCOUT_ENDPOINT:-http://localhost:4318}
- SCOUT_CLIENT_ID=${SCOUT_CLIENT_ID:-}
- SCOUT_CLIENT_SECRET=${SCOUT_CLIENT_SECRET:-}
- SCOUT_TOKEN_URL=${SCOUT_TOKEN_URL:-}
- SCOUT_ENVIRONMENT=${SCOUT_ENVIRONMENT:-development}
networks:
- app-network
volumes:
postgres-data:
networks:
app-network:
driver: bridge