-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-compose.prod.yml
200 lines (192 loc) · 4.77 KB
/
docker-compose.prod.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
x-common-labels: &common-labels
environment: "production"
x-common-security: &common-security
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
x-logging: &logging
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
services:
postgres-prod:
container_name: zephyr-postgres-prod
build:
context: .
dockerfile: ./docker/postgres/Dockerfile.prod
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_PORT=${POSTGRES_PORT}
- POSTGRES_HOST=${POSTGRES_HOST}
- DATABASE_URL=${DATABASE_URL}
- POSTGRES_PRISMA_URL=${POSTGRES_PRISMA_URL}
- POSTGRES_URL_NON_POOLING=${POSTGRES_URL_NON_POOLING}
ports:
- "${POSTGRES_PORT}:5432"
volumes:
- postgres_data_prod:/var/lib/postgresql/data
- postgres_logs_prod:/var/log/postgresql
command: ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
networks:
- prod_network
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '1'
memory: 1G
security_opt:
- no-new-privileges:true
cap_add:
- CHOWN
- FOWNER
- SETGID
- SETUID
shm_size: '256mb'
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
<<: [*common-labels, *logging]
healthcheck:
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s
restart: always
redis-prod:
container_name: zephyr-redis-prod
build:
context: .
dockerfile: ./docker/redis/Dockerfile.prod
ports:
- "${REDIS_PORT}:6379"
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_MAXMEMORY=4gb
- REDIS_MAXMEMORY_POLICY=allkeys-lru
volumes:
- redis_data_prod:/data
- ./docker/redis/prod/redis.conf:/usr/local/etc/redis/redis.conf:ro
networks:
- prod_network
deploy:
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '1'
memory: 2G
<<: [*common-labels, *common-security, *logging]
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
interval: 30s
timeout: 5s
retries: 3
restart: always
minio-prod:
container_name: zephyr-minio-prod
build:
context: .
dockerfile: ./docker/minio/Dockerfile.prod
ports:
- "${MINIO_PORT}:9000"
- "${MINIO_CONSOLE_PORT}:9001"
environment:
- MINIO_ROOT_USER=${MINIO_ROOT_USER}
- MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD}
- MINIO_BROWSER_REDIRECT_URL=${MINIO_BROWSER_REDIRECT_URL:-http://localhost:9001}
- MINIO_PROMETHEUS_AUTH_TYPE=public
volumes:
- minio_data_prod:/data
networks:
- prod_network
deploy:
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '1'
memory: 2G
<<: [*common-labels, *common-security, *logging]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 5s
retries: 3
restart: always
web:
build:
context: .
dockerfile: ./apps/web/Dockerfile.prod
ports:
- "${NEXT_PUBLIC_PORT}:3000"
environment:
- NODE_ENV=production
- DATABASE_URL=${DATABASE_URL}
- REDIS_URL=redis://:${REDIS_PASSWORD}@redis-prod:6379/0
- MINIO_ENDPOINT=${MINIO_ENDPOINT}
depends_on:
postgres-prod:
condition: service_healthy
redis-prod:
condition: service_healthy
minio-prod:
condition: service_healthy
networks:
- prod_network
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '1'
memory: 2G
<<: [*common-labels, *common-security, *logging]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
interval: 30s
timeout: 5s
retries: 3
restart: always
networks:
prod_network:
driver: bridge
name: zephyr_prod_network
driver_opts:
encrypted: "true"
labels:
<<: *common-labels
volumes:
postgres_data_prod:
name: zephyr_postgres_data_prod
labels:
<<: *common-labels
redis_data_prod:
name: zephyr_redis_data_prod
labels:
<<: *common-labels
minio_data_prod:
name: zephyr_minio_data_prod
labels:
<<: *common-labels
postgres_logs_prod:
name: zephyr_postgres_logs_prod
labels:
<<: *common-labels