-
Notifications
You must be signed in to change notification settings - Fork 7
/
docker-compose-production.yml
257 lines (247 loc) · 8.83 KB
/
docker-compose-production.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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
version: '3.9'
services:
site:
image: ${REGISTRY}/site:${IMAGE_TAG}
networks:
- traefik-public
- default
volumes:
- site-assets:/app/public/assets:ro
- site-upload:/app/public/upload:ro
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.http.services.site.loadbalancer.server.port=80
- traefik.http.routers.site.rule=Host(`elisdn.ru`) || Host(`www.elisdn.ru`)
- traefik.http.middlewares.site-redirect.redirectregex.regex=^(https?://)www.elisdn.ru/(.*)$$
- traefik.http.middlewares.site-redirect.redirectregex.replacement=$${1}elisdn.ru/$${2}
- traefik.http.middlewares.site-redirect.redirectregex.permanent=true
- traefik.http.routers.site.middlewares=site-redirect,secure-headers
- traefik.http.routers.site.entrypoints=https
- traefik.http.routers.site.tls=true
- traefik.http.routers.site.tls.certresolver=letsencrypt
replicas: 2
update_config:
parallelism: 1
delay: 10s
placement:
constraints: [ node.role == manager ]
site-php-fpm:
image: ${REGISTRY}/site-php-fpm:${IMAGE_TAG}
environment:
APP_DEBUG: 0
APP_ENV: prod
APP_URL: https://elisdn.ru
COOKIE_SECRET_FILE: /run/secrets/cookie_secret
DB_HOST: site-mysql
DB_NAME: app
DB_USERNAME: app
DB_PASSWORD_FILE: /run/secrets/db_password
REDIS_HOST: site-redis
REDIS_PASSWORD_FILE: /run/secrets/redis_password
MAILER_HOST: ${MAILER_HOST}
MAILER_PORT: ${MAILER_PORT}
MAILER_USERNAME: ${MAILER_USERNAME}
MAILER_PASSWORD_FILE: /run/secrets/mailer_password
MAILER_FROM_EMAIL: ${MAILER_FROM_EMAIL}
DEWORKER_API_URL: https://api.deworker.pro
SENTRY_DSN_FILE: /run/secrets/sentry_dsn
secrets:
- cookie_secret
- db_password
- redis_password
- mailer_password
- sentry_dsn
volumes:
- site-assets:/app/public/assets
- site-upload:/app/public/upload
deploy:
replicas: 2
update_config:
parallelism: 1
delay: 20s
placement:
constraints: [ node.role == manager ]
site-migration:
image: ${REGISTRY}/site-php-cli:${IMAGE_TAG}
environment:
APP_DEBUG: 0
APP_ENV: prod
APP_URL: https://elisdn.ru
COOKIE_SECRET_FILE: /run/secrets/cookie_secret
DB_HOST: site-mysql
DB_NAME: app
DB_USERNAME: app
DB_PASSWORD_FILE: /run/secrets/db_password
REDIS_HOST: site-redis
REDIS_PASSWORD_FILE: /run/secrets/redis_password
MAILER_HOST: ${MAILER_HOST}
MAILER_PORT: ${MAILER_PORT}
MAILER_USERNAME: ${MAILER_USERNAME}
MAILER_PASSWORD_FILE: /run/secrets/mailer_password
MAILER_FROM_EMAIL: ${MAILER_FROM_EMAIL}
DEWORKER_API_URL: https://api.deworker.pro
SENTRY_DSN_FILE: /run/secrets/sentry_dsn
secrets:
- cookie_secret
- db_password
- redis_password
- mailer_password
- sentry_dsn
volumes:
- site-assets:/app/public/assets
- site-upload:/app/public/upload
command: sh -c "wait-for-it site-mysql:3306 -t 60 && php bin/app.php migrate --interactive=0"
deploy:
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 5
window: 120s
placement:
constraints: [ node.role == manager ]
site-cache-flush:
image: ${REGISTRY}/site-php-cli:${IMAGE_TAG}
environment:
APP_DEBUG: 0
APP_ENV: prod
APP_URL: https://elisdn.ru
COOKIE_SECRET_FILE: /run/secrets/cookie_secret
DB_HOST: site-mysql
DB_NAME: app
DB_USERNAME: app
DB_PASSWORD_FILE: /run/secrets/db_password
REDIS_HOST: site-redis
REDIS_PASSWORD_FILE: /run/secrets/redis_password
MAILER_HOST: ${MAILER_HOST}
MAILER_PORT: ${MAILER_PORT}
MAILER_USERNAME: ${MAILER_USERNAME}
MAILER_PASSWORD_FILE: /run/secrets/mailer_password
MAILER_FROM_EMAIL: ${MAILER_FROM_EMAIL}
DEWORKER_API_URL: https://api.deworker.pro
SENTRY_DSN_FILE: /run/secrets/sentry_dsn
secrets:
- cookie_secret
- db_password
- redis_password
- mailer_password
- sentry_dsn
volumes:
- site-assets:/app/public/assets
- site-upload:/app/public/upload
command: sh -c "wait-for-it site-redis:6379 -t 60 && php bin/app.php cache/flush cache --interactive=0"
deploy:
update_config:
delay: 40s
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 5
window: 120s
placement:
constraints: [ node.role == manager ]
site-mysql:
image: mariadb:11
environment:
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
MYSQL_USER: app
MYSQL_PASSWORD_FILE: /run/secrets/db_password
MYSQL_DATABASE: app
secrets:
- db_root_password
- db_password
volumes:
- site-mysql:/var/lib/mysql
deploy:
placement:
constraints: [ node.labels.db == db ]
endpoint_mode: dnsrr
site-mysql-backup:
image: ${REGISTRY}/site-mysql-backup:${IMAGE_TAG}
environment:
BACKUP_NAME: site-mysql
MYSQL_HOST: site-mysql
MYSQL_USER: app
MYSQL_PASSWORD_FILE: /run/secrets/db_password
MYSQL_DB: app
AWS_ACCESS_KEY_ID: ${BACKUP_AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY_FILE: /run/secrets/backup_aws_secret_access_key
AWS_DEFAULT_REGION: ${BACKUP_AWS_DEFAULT_REGION}
S3_ENDPOINT: ${BACKUP_S3_ENDPOINT}
S3_BUCKET: ${BACKUP_S3_BUCKET}
secrets:
- db_password
- backup_aws_secret_access_key
command: sh -c "wait-for-it site-mysql:3306 -t 60 && backup"
deploy:
labels:
- swarm.cronjob.enable=true
- swarm.cronjob.schedule=0 */3 * * *
- swarm.cronjob.skip-running=true
replicas: 0
restart_policy:
condition: none
site-upload-backup:
image: ${REGISTRY}/site-files-backup:${IMAGE_TAG}
environment:
BACKUP_NAME: site-upload
TARGET: /upload
AWS_ACCESS_KEY_ID: ${BACKUP_AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY_FILE: /run/secrets/backup_aws_secret_access_key
AWS_DEFAULT_REGION: ${BACKUP_AWS_DEFAULT_REGION}
S3_ENDPOINT: ${BACKUP_S3_ENDPOINT}
S3_BUCKET: ${BACKUP_S3_BUCKET}
secrets:
- backup_aws_secret_access_key
volumes:
- site-upload:/upload:ro
deploy:
labels:
- swarm.cronjob.enable=true
- swarm.cronjob.schedule=30 0 * * *
- swarm.cronjob.skip-running=true
replicas: 0
restart_policy:
condition: none
placement:
constraints: [ node.role == manager ]
site-redis:
image: ${REGISTRY}/site-redis:7.0
environment:
REDIS_PASSWORD_FILE: /run/secrets/redis_password
secrets:
- redis_password
volumes:
- site-redis:/data
command:
- 'redis-server'
- '--maxmemory 32mb'
- '--maxmemory-policy allkeys-lru'
deploy:
placement:
constraints: [ node.labels.db == db ]
endpoint_mode: dnsrr
secrets:
cookie_secret:
file: ./secrets/cookie_secret
db_password:
file: ./secrets/db_password
db_root_password:
file: ./secrets/db_root_password
redis_password:
file: ./secrets/redis_password
mailer_password:
file: ./secrets/mailer_password
sentry_dsn:
file: ./secrets/sentry_dsn
backup_aws_secret_access_key:
file: ./secrets/backup_aws_secret_access_key
volumes:
site-assets:
site-upload:
site-mysql:
site-redis:
networks:
traefik-public:
external: true