-
Notifications
You must be signed in to change notification settings - Fork 56
/
docker-compose.yml
203 lines (190 loc) · 4.91 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
services:
bot:
build:
context: .
dockerfile: ./Dockerfile
image: bot:latest
container_name: ${COMPOSE_PROJECT_NAME}-bot
restart: always
env_file:
- .env
ports:
- ${WEBHOOK_PORT}:${WEBHOOK_PORT}
networks:
- app
- monitoring
depends_on:
- pgbouncer
- redis
admin:
build:
context: .
dockerfile: ./admin/Dockerfile
container_name: ${COMPOSE_PROJECT_NAME}-admin
restart: always
env_file:
- .env
ports:
- ${ADMIN_PORT}:${ADMIN_PORT}
networks:
- app
depends_on:
- bot
volumes:
- ./admin:/usr/src/app/admin
postgres:
image: postgres:14-alpine
container_name: ${COMPOSE_PROJECT_NAME}-postgres
restart: always
env_file:
- .env
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASS}
- POSTGRES_DB=${DB_NAME}
- PGDATA='/var/lib/postgresql/data/pgdata'
networks:
- app
volumes:
- postgres-data:/var/lib/postgresql/data
pgbouncer:
image: edoburu/pgbouncer
container_name: ${COMPOSE_PROJECT_NAME}-pgbouncer
restart: always
env_file:
- .env
environment:
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASS}
- DB_HOST=postgres
- POOL_MODE=session
- MAX_DB_CONNECTIONS=0
- DEFAULT_POOL_SIZE=40
- ADMIN_USERS=postgres,${DB_USER}
- AUTH_TYPE=scram-sha-256
ports:
- ${DB_PORT}:${DB_PORT}
depends_on:
- postgres
networks:
- app
pgbackup:
container_name: ${COMPOSE_PROJECT_NAME}-pgbackup
image: prodrigestivill/postgres-backup-local
restart: always
volumes:
- backups-data:/backups
networks:
- app
depends_on:
- postgres
environment:
- POSTGRES_HOST=postgres
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASS}
- POSTGRES_EXTRA_OPTS=-Z9 --schema=public --blobs
- SCHEDULE=@every 0h30m00s
- BACKUP_KEEP_DAYS=7
- BACKUP_KEEP_WEEKS=4
- BACKUP_KEEP_MONTHS=6
- HEALTHCHECK_PORT=81
redis:
image: redis:7-alpine
container_name: ${COMPOSE_PROJECT_NAME}-redis
restart: always
env_file:
- .env
ports:
- ${REDIS_PORT}:${REDIS_PORT}
networks:
- app
volumes:
- redis-data:/bitnami/redis/data
command: /bin/sh -c 'if [ -n "$REDIS_PASS" ]; then redis-server --requirepass "$REDIS_PASS"; else redis-server; fi'
migrator:
image: bot:latest
container_name: ${COMPOSE_PROJECT_NAME}-migrator
restart: "on-failure"
command: alembic upgrade head
env_file:
- .env
networks:
- app
depends_on:
- bot
volumes:
- ./migrations:/usr/src/app/migrations
# MONITORING
node-exporter:
image: prom/node-exporter:latest
container_name: ${COMPOSE_PROJECT_NAME}-node-exporter
restart: unless-stopped
ports:
- 9100:9100
networks:
- monitoring
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- "--path.procfs=/host/proc"
- "--path.sysfs=/host/sys"
- "--collector.filesystem.mount-points-exclude"
- "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)"
prometheus:
image: prom/prometheus:v2.43.0
container_name: ${COMPOSE_PROJECT_NAME}-prometheus
restart: unless-stopped
env_file:
- .env
ports:
- ${PROMETHEUS_PORT}:${PROMETHEUS_PORT}
depends_on:
- bot
- node-exporter
networks:
- monitoring
volumes:
- ./configs/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--web.console.libraries=/etc/prometheus/console_libraries"
- "--web.console.templates=/etc/prometheus/consoles"
- "--web.enable-lifecycle"
grafana:
image: grafana/grafana:8.5.22
container_name: ${COMPOSE_PROJECT_NAME}-grafana
restart: always
env_file:
- .env
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
- GF_INSTALL_PLUGINS=grafana-clock-panel
ports:
- ${GRAFANA_PORT}:${GRAFANA_PORT}
depends_on:
- prometheus
networks:
- monitoring
volumes:
- ./configs/grafana/datasources:/etc/grafana/provisioning/datasources
- ./configs/grafana/dashboards:/etc/grafana/provisioning/dashboards
- ./configs/grafana/node-exporter.json:/var/lib/grafana/dashboards/node-exporter.json
- grafana-data:/var/lib/grafana
user: "0"
networks:
app:
driver: bridge
monitoring:
driver: bridge
volumes:
backups-data: {}
postgres-data: {}
redis-data: {}
prometheus-data: {}
grafana-data: {}