-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.yml
More file actions
187 lines (180 loc) · 4.83 KB
/
compose.yml
File metadata and controls
187 lines (180 loc) · 4.83 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
x-default-logging: &logging
driver: "json-file"
options:
max-size: "5m"
max-file: "2"
services:
web:
build: .
restart: unless-stopped
command: opentelemetry-instrument uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
volumes:
- .:/app
- /app/.venv
ports:
- "8000:8000"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: task_db
POSTGRES_HOST: db
REDIS_HOST: redis
RABBITMQ_HOST: rabbitmq
RABBITMQ_USER: guest
RABBITMQ_PASSWORD: guest
OTEL_SERVICE_NAME: fastapi-celery-postgres-web
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
OTEL_TRACES_EXPORTER: otlp
OTEL_METRICS_EXPORTER: otlp
OTEL_LOGS_EXPORTER: otlp
OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED: "true"
depends_on:
rabbitmq:
condition: service_healthy
redis:
condition: service_healthy
db:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/ping"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
logging: *logging
develop:
watch:
- action: sync
path: ./app
target: /app/app
celery_worker:
build: .
restart: unless-stopped
command: opentelemetry-instrument celery -A app.tasks.celery worker --loglevel=info
volumes:
- .:/app
- /app/.venv
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: task_db
POSTGRES_HOST: db
REDIS_HOST: redis
RABBITMQ_HOST: rabbitmq
RABBITMQ_USER: guest
RABBITMQ_PASSWORD: guest
OTEL_SERVICE_NAME: fastapi-celery-postgres-worker
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
OTEL_TRACES_EXPORTER: otlp
OTEL_METRICS_EXPORTER: otlp
OTEL_LOGS_EXPORTER: otlp
OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED: "true"
depends_on:
rabbitmq:
condition: service_healthy
redis:
condition: service_healthy
db:
condition: service_healthy
web:
condition: service_healthy
healthcheck:
test: ["CMD", "celery", "-A", "app.tasks.celery", "inspect", "ping"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
logging: *logging
develop:
watch:
- action: sync+restart
path: ./app
target: /app/app
db:
image: postgres:18-alpine
restart: unless-stopped
shm_size: 128mb
volumes:
- postgres_data:/var/lib/postgresql
- ./scripts/init-monitoring-user.sql:/docker-entrypoint-initdb.d/init-monitoring-user.sql:ro
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: task_db
ports:
- "5432:5432"
logging: *logging
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres", "-d", "task_db", "-h", "localhost"]
interval: 30s
timeout: 5s
retries: 5
start_period: 10s
redis:
image: redis:8.0-alpine
restart: unless-stopped
ports:
- "6379:6379"
logging: *logging
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 5s
retries: 5
start_period: 5s
rabbitmq:
image: rabbitmq:4.0-management-alpine
restart: unless-stopped
ports:
- "5672:5672"
- "15672:15672"
environment:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
volumes:
- ./config/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
- ./config/rabbit-config.json:/etc/rabbitmq/definitions.json:ro
logging: *logging
healthcheck:
test: ["CMD", "rabbitmqctl", "status"]
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
otel-collector:
image: otel/opentelemetry-collector-contrib:0.147.0
container_name: otel-collector
deploy:
resources:
limits:
memory: 256M
restart: unless-stopped
command: ["--config=/etc/otel-config.yaml"]
volumes:
- ./config/otel-config.yaml:/etc/otel-config.yaml:ro
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}
ports:
- "4318:4318"
- "4317:4317"
- "13133:13133"
- "55679:55679"
logging: *logging
depends_on:
rabbitmq:
condition: service_healthy
db:
condition: service_healthy
redis:
condition: service_healthy
volumes:
postgres_data: