Repository navigation
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
174 lines (161 loc) · 4.68 KB
/
Copy pathdocker-compose.prod.yml
File metadata and controls
174 lines (161 loc) · 4.68 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
version: "3.8"
name: punoted-backend
services:
# ==============================================================================
# 1. CORE INFRASTRUCTURE (Main App)
# ==============================================================================
# --- MAIN DATABASE ---
prod_db:
image: postgres:15.12-alpine
container_name: punoted_prod_db
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASS}
POSTGRES_DB: ${DB_NAME}
ports:
- "127.0.0.1:5445:5432"
volumes:
- prod_data:/var/lib/postgresql/data
networks:
- punoted_prod_net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 5s
timeout: 5s
retries: 5
# --- SHARED REDIS ---
redis_cache:
image: redis:alpine
container_name: punoted_redis_prod
command: redis-server --save 60 1 --loglevel warning
ports:
- "127.0.0.1:6379:6379"
volumes:
- redis_data:/data
networks:
- punoted_prod_net
# --- API BACKEND ---
backend:
image: ghcr.io/xflasar/punoted-api:main
container_name: punoted_backend_prod
#build:
# context: . # The directory containing Dockerfile
# dockerfile: Dockerfile
depends_on:
redis_cache:
condition: service_started
prod_db:
condition: service_healthy
env_file:
- .env
environment:
- REDIS_URL=redis://redis_cache:6379/0
- DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@prod_db:5432/${DB_NAME}
- XATA_DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@prod_db:5432/${DB_NAME}
ports:
- "127.0.0.1:9901:9901"
networks:
- punoted_prod_net
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 9901 || exit 1"]
interval: 30s
timeout: 10s
retries: 3
deploy:
resources:
limits:
cpus: 3
background_worker:
image: ghcr.io/xflasar/punoted-api:main
container_name: punoted_background_prod
#build:
# context: . # Re-uses the same local Dockerfile definition
# dockerfile: Dockerfile
command: ["python", "run_background.py"]
depends_on:
redis_cache:
condition: service_started
prod_db:
condition: service_healthy
env_file:
- .env
environment:
- REDIS_URL=redis://redis_cache:6379/0
- DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@prod_db:5432/${DB_NAME}
- XATA_DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@prod_db:5432/${DB_NAME}
networks:
- punoted_prod_net
restart: always
# ==============================================================================
# 2. MONITORING STACK
# ==============================================================================
prometheus:
image: prom/prometheus:latest
container_name: punoted_prometheus
volumes:
- ./config/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--web.console.libraries=/usr/share/prometheus/console_libraries"
- "--web.console.templates=/usr/share/prometheus/consoles"
ports:
- "9090:9090"
networks:
- punoted_prod_net
grafana:
image: grafana/grafana:latest
container_name: punoted_grafana
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
networks:
- punoted_prod_net
depends_on:
- prometheus
cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
container_name: punoted_cadvisor
ports:
- "8080:8080"
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
# Remove below line if on Windows
- /dev/disk/:/dev/disk:ro
networks:
- punoted_prod_net
db_maintenance:
build: ./maintenance
container_name: db_maintenance_worker
environment:
PGHOST: prod_db
PGUSER: ${DB_USER}
PGPASSWORD: ${DB_PASS}
PGDATABASE: ${DB_NAME}
volumes:
# Persist backups to the host machine
- ./backups:/backups
- ./config/rclone.conf:/config/rclone.conf:ro
depends_on:
prod_db:
condition: service_healthy
networks:
- punoted_prod_net
# ==============================================================================
# NETWORKS & VOLUMES
# ==============================================================================
networks:
punoted_prod_net:
driver: bridge
volumes:
prod_data: # Main App Data
redis_data: # Shared Cache
grafana_data: # Monitoring Configs
prometheus_data: # Metrics History