-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose.yml
233 lines (218 loc) · 5.49 KB
/
docker-compose.yml
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
services:
bot:
container_name: "fanfan-bot-${ENV_NAME}"
build: .
env_file:
- .env
restart: unless-stopped
volumes:
- bot-data:/media/bot-data
ports:
- "127.0.0.1:${BOT__WEBHOOK__PORT}:${BOT__WEBHOOK__PORT}"
depends_on:
- migration
- redis
- nats
command: ["python", "-m", "fanfan.main.bot"]
web:
profiles: [ "web" ]
container_name: "fanfan-web-${ENV_NAME}"
build: .
env_file:
- .env
restart: unless-stopped
stop_signal: SIGINT
volumes:
- bot-data:/media/bot-data
ports:
- "127.0.0.1:${WEB__PORT}:${WEB__PORT}"
depends_on:
- migration
command: [
"python",
"-m",
"fanfan.main.web",
]
migration:
container_name: "fanfan-migration-${ENV_NAME}"
build: .
restart: on-failure
env_file:
- .env
volumes:
- bot-data:/media/bot-data
- ./alembic.ini:/app/alembic.ini
depends_on:
db:
condition: service_healthy
command: ["sh", "-c", "alembic upgrade head && python -m fanfan.main.migration"]
db:
container_name: "fanfan-db-${ENV_NAME}"
image: postgres:17-alpine
restart: always
env_file:
- .env
environment:
- POSTGRES_USER=${DB__USER}
- POSTGRES_PASSWORD=${DB__PASSWORD}
- POSTGRES_DB=${DB__NAME}
volumes:
- db-data:/var/lib/postgresql/data
ports:
- "127.0.0.1:${DB__EXPOSED_PORT}:5432"
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}" ]
interval: 2s
timeout: 60s
retries: 10
start_period: 5s
pgbackup:
container_name: "fanfan-db-backup-${ENV_NAME}"
image: prodrigestivill/postgres-backup-local
restart: always
volumes:
- pgbackup-data:/backups
depends_on:
- db
environment:
- POSTGRES_HOST=db
- POSTGRES_DB=${DB__NAME}
- POSTGRES_USER=${DB__USER}
- POSTGRES_PASSWORD=${DB__PASSWORD}
- POSTGRES_EXTRA_OPTS=-Z1 --schema=public --blobs
- SCHEDULE=@every 6h00m00s
- BACKUP_ON_START=TRUE
- BACKUP_KEEP_DAYS=7
- BACKUP_KEEP_WEEKS=4
- BACKUP_KEEP_MONTHS=6
redis:
image: redis:7-alpine
container_name: "fanfan-redis-${ENV_NAME}"
command: "redis-server /usr/local/etc/redis/redis.conf --requirepass ${REDIS__PASSWORD}"
env_file:
- .env
restart: always
volumes:
- redis-data:/data
- ./config/redis/redis.conf:/usr/local/etc/redis/redis.conf
ports:
- "127.0.0.1:${REDIS__EXPOSED_PORT}:6379"
healthcheck:
test: [ "CMD", "redis-cli","ping" ]
interval: 5s
timeout: 20s
retries: 5
nats:
container_name: "fanfan-nats-${ENV_NAME}"
image: docker.io/nats:alpine
restart: always
env_file:
- .env
ports:
- "127.0.0.1:${NATS__EXPOSED_PORT}:4222"
volumes:
- nats-data:/data
command: "--js --sd=/data --user ${NATS__USER} --pass ${NATS__PASSWORD}"
faststream:
container_name: "fanfan-faststream-${ENV_NAME}"
build: .
restart: unless-stopped
env_file:
- .env
volumes:
- bot-data:/media/bot-data
depends_on:
- nats
- migration
- redis
command: ["python", "-m", "fanfan.main.stream"]
taskiq:
container_name: "fanfan-taskiq-${ENV_NAME}"
build: .
restart: unless-stopped
env_file:
- .env
volumes:
- bot-data:/media/bot-data
depends_on:
- migration
- redis
- nats
command:
[
"taskiq",
"worker",
"fanfan.main.scheduler:broker",
"fanfan.presentation.scheduler.tasks",
]
scheduler:
profiles: ["scheduler"]
container_name: "fanfan-scheduler-${ENV_NAME}"
build: .
depends_on:
- redis
restart: unless-stopped
env_file:
- .env
volumes:
- bot-data:/media/bot-data
command:
[
"taskiq",
"scheduler",
"fanfan.main.scheduler:scheduler",
"fanfan.presentation.scheduler.tasks",
]
grafana:
profiles: [ "grafana" ]
image: grafana/grafana:latest
container_name: "fanfan-grafana-${ENV_NAME}"
restart: unless-stopped
ports:
- "127.0.0.1:3000:3000"
volumes:
- grafana-data:/var/lib/grafana:rw
- ./config/grafana/provisioning:/etc/grafana/provisioning:rw
- ./config/grafana/dashboards:/etc/grafana/dashboards
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
- GF_USERS_ALLOW_SIGN_UP=false
- GF_DATABASE_WAL=true
- VIRTUAL_HOST=grafana
- NETWORK_ACCESS=internal
- VIRTUAL_PORT=3000
tempo:
profiles: [ "grafana" ]
image: grafana/tempo:latest
container_name: "fanfan-tempo-${ENV_NAME}"
command: [ "-config.file=/etc/tempo.yaml" ]
volumes:
- tempo-data:/var/tempo
- ./config/tempo/tempo.yaml:/etc/tempo.yaml
restart: unless-stopped
ports:
- "14250:14250"
- "4317:4317"
- "3200:3200"
prometheus:
profiles: [ "grafana" ]
image: prom/prometheus:latest
container_name: "fanfan-prometheus-${ENV_NAME}"
command:
- --config.file=/etc/prometheus.yaml
- --web.enable-remote-write-receiver
- --enable-feature=exemplar-storage
volumes:
- ./config/prometheus/prometheus.yaml:/etc/prometheus.yaml
ports:
- "9090:9090"
volumes:
bot-data: {}
db-data: {}
pgbackup-data: {}
redis-data: {}
nats-data: {}
grafana-data: {}
tempo-data: {}
loki-data: {}