-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
194 lines (185 loc) · 5.72 KB
/
docker-compose.prod.yml
File metadata and controls
194 lines (185 loc) · 5.72 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
188
189
190
191
192
193
194
services:
traefik:
image: traefik:v3.3
ports:
- "80:80"
# - "443:443" # Commented out as TLS termination is handled by jump host edge router
# - "8080:8080" # Dashboard not needed in production
volumes:
- ./traefik/traefik.yml:/etc/traefik/traefik.yml
# - ./traefik/acme.json:/acme.json # Not needed when TLS termination is handled externally
- /var/run/docker.sock:/var/run/docker.sock
networks:
- app-network
restart: always
healthcheck:
test: ["CMD", "traefik", "healthcheck", "--ping"]
interval: 10s
timeout: 5s
retries: 3
db:
image: postgres:16
restart: always
environment:
POSTGRES_USER: ${DB_USER:-user}
POSTGRES_PASSWORD: ${DB_PASSWORD:-password}
POSTGRES_DB: ${DB_NAME:-dbname}
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- app-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-user} -d ${DB_NAME:-dbname}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
redis:
image: redis:7-alpine
restart: always
volumes:
- redis_data:/data
networks:
- app-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
backend:
build:
context: ./backend
dockerfile: Dockerfile.production
restart: always
depends_on:
- db
- redis
volumes:
- ./validator:/validator
env_file:
- ./backend/.env
environment:
- DATABASE_URL=postgresql+asyncpg://${DB_USER:-user}:${DB_PASSWORD:-password}@db:5432/${DB_NAME:-dbname}
- SYNC_DATABASE_URL=postgresql://${DB_USER:-user}:${DB_PASSWORD:-password}@db:5432/${DB_NAME:-dbname}
- ENVIRONMENT=${ENVIRONMENT:-production}
- CELERY_BROKER_URL=redis://redis:6379/${REDIS_BROKER_DB:-0}
- CELERY_RESULT_BACKEND=redis://redis:6379/${REDIS_RESULT_DB:-0}
networks:
- app-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/health-check"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
labels:
- "traefik.enable=${BACKEND_TRAEFIK_ENABLED:-true}"
- "traefik.http.routers.backend.rule=PathPrefix(`/api`)"
- "traefik.http.routers.backend.entrypoints=web"
- "traefik.http.services.backend.loadbalancer.server.port=8000"
celery-worker:
build:
context: ./backend
dockerfile: Dockerfile.production
restart: always
depends_on:
- db
- redis
volumes:
- ./validator:/validator
env_file:
- ./backend/.env
environment:
- DATABASE_URL=postgresql+asyncpg://${DB_USER:-user}:${DB_PASSWORD:-password}@db:5432/${DB_NAME:-dbname}
- SYNC_DATABASE_URL=postgresql://${DB_USER:-user}:${DB_PASSWORD:-password}@db:5432/${DB_NAME:-dbname}
- ENVIRONMENT=${ENVIRONMENT:-production}
- CELERY_BROKER_URL=redis://redis:6379/${REDIS_BROKER_DB:-0}
- CELERY_RESULT_BACKEND=redis://redis:6379/${REDIS_RESULT_DB:-0}
networks:
- app-network
healthcheck:
test: ["CMD-SHELL", "celery -A app.core.celery_app inspect ping"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
command: >
celery -A app.core.celery_app worker --concurrency=1 --pool=solo --loglevel=info
celery-beat:
build:
context: ./backend
dockerfile: Dockerfile.production
restart: always
depends_on:
- redis
- celery-worker
volumes:
- ./validator:/validator
env_file:
- ./backend/.env
environment:
- DATABASE_URL=postgresql+asyncpg://${DB_USER:-user}:${DB_PASSWORD:-password}@db:5432/${DB_NAME:-dbname}
- SYNC_DATABASE_URL=postgresql://${DB_USER:-user}:${DB_PASSWORD:-password}@db:5432/${DB_NAME:-dbname}
- ENVIRONMENT=${ENVIRONMENT:-production}
- CELERY_BROKER_URL=redis://redis:6379/${REDIS_BROKER_DB:-0}
- CELERY_RESULT_BACKEND=redis://redis:6379/${REDIS_RESULT_DB:-0}
networks:
- app-network
healthcheck:
test: ["CMD", "celery", "-A", "app.core.celery_app", "inspect", "ping"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
command: >
celery -A app.core.celery_app beat --loglevel=info
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.production
restart: always
env_file:
- ./frontend/.env
depends_on:
- backend
networks:
- app-network
command: ["nginx", "-g", "daemon off;"]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
labels:
- "traefik.enable=${FRONTEND_TRAEFIK_ENABLED:-true}"
- "traefik.http.routers.frontend.rule=PathPrefix(`/`) && !PathPrefix(`/api`)"
- "traefik.http.routers.frontend.entrypoints=web"
- "traefik.http.services.frontend.loadbalancer.server.port=80"
- "traefik.http.routers.frontend.priority=1"
maintenance:
image: nginx:alpine
restart: always
networks:
- app-network
volumes:
- ./maintenance:/usr/share/nginx/html
labels:
- "traefik.enable=${MAINTENANCE_TRAEFIK_ENABLED:-false}"
- "traefik.http.routers.maintenance.rule=PathPrefix(`/`) && !PathPrefix(`/api`)"
- "traefik.http.routers.maintenance.entrypoints=web"
- "traefik.http.services.maintenance.loadbalancer.server.port=80"
- "traefik.http.routers.maintenance.priority=100"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
volumes:
postgres_data:
redis_data:
networks:
app-network:
driver: bridge