-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-stack.yml
184 lines (172 loc) · 6.74 KB
/
docker-stack.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
version: '3.6'
services:
redis:
deploy:
replicas: 1
update_config:
parallelism: 1
order: stop-first
placement:
constraints:
- node.labels.${ENVIRONMENT} == true
db:
environment:
POSTGRES_PASSWORD_FILE: /run/secrets/postgres-password
secrets:
- postgres-password
deploy:
replicas: 1
update_config:
parallelism: 1
order: stop-first
placement:
constraints:
- node.labels.${ENVIRONMENT} == true
backend: &backend
image: $CONTAINER_IMAGE
configs:
- source: backned-config
target: .env
secrets:
- postgres-password
- flower-password
networks:
- default
- traefik-public
deploy:
placement:
constraints:
- node.labels.${ENVIRONMENT} == true
mode: replicated
replicas: 1
update_config:
parallelism: 1
order: start-first
failure_action: rollback
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.routers.${STACK_NAME}-backend-http.entrypoints=http
- traefik.http.routers.${STACK_NAME}-backend-http.rule=Host(`${DOMAIN?Variable not set}`) && (PathPrefix(`/api`) || PathPrefix(`/flasgger_static`))
- traefik.http.routers.${STACK_NAME}-backend-http.service=${STACK_NAME}-backend
- traefik.http.routers.${STACK_NAME}-backend-http.middlewares=https-redirect
- traefik.http.routers.${STACK_NAME}-backend.entrypoints=https
- traefik.http.routers.${STACK_NAME}-backend.rule=Host(`${DOMAIN?Variable not set}`) && (PathPrefix(`/api`) || PathPrefix(`/flasgger_static`))
- traefik.http.routers.${STACK_NAME}-backend.service=${STACK_NAME}-backend
- traefik.http.routers.${STACK_NAME}-backend.tls=true
- traefik.http.routers.${STACK_NAME}-backend.tls.certresolver=le
- traefik.http.services.${STACK_NAME}-backend.loadbalancer.server.port=5000
worker: &worker
<<: *backend
deploy:
placement:
constraints:
- node.labels.${ENVIRONMENT} == true
mode: replicated
replicas: 1
labels:
- traefik.enable=false
update_config:
parallelism: 1
order: start-first
failure_action: rollback
slow-worker:
<<: *worker
command: celery -A say.celery worker --autoscale=4,1 --loglevel=WARNING -S redbeat.RedBeatScheduler -Q slow -Ofair
flower:
<<: *worker
deploy:
placement:
constraints:
- node.labels.${ENVIRONMENT} == true
mode: replicated
replicas: 1
update_config:
parallelism: 1
order: start-first
failure_action: rollback
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.routers.${STACK_NAME}-flower-http.entrypoints=http
- traefik.http.routers.${STACK_NAME}-flower-http.rule=Host(`flower.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME}-flower-http.service=${STACK_NAME}-flower
- traefik.http.routers.${STACK_NAME}-flower-http.middlewares=https-redirect
- traefik.http.routers.${STACK_NAME}-flower.entrypoints=https
- traefik.http.routers.${STACK_NAME}-flower.rule=Host(`flower.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME}-flower.service=${STACK_NAME}-flower
- traefik.http.routers.${STACK_NAME}-flower.tls=true
- traefik.http.routers.${STACK_NAME}-flower.tls.certresolver=le
- traefik.http.services.${STACK_NAME}-flower.loadbalancer.server.port=5555
media:
networks:
- traefik-public
deploy:
placement:
constraints:
- node.labels.${ENVIRONMENT} == true
mode: replicated
replicas: 1
update_config:
parallelism: 1
order: start-first
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.routers.${STACK_NAME}-media-http.entrypoints=http
- traefik.http.routers.${STACK_NAME}-media-http.rule=Host(`${DOMAIN?Variable not set}`) && PathPrefix(`/files`)
- traefik.http.routers.${STACK_NAME}-media-http.service=${STACK_NAME}-media
- traefik.http.routers.${STACK_NAME}-media-http.middlewares=https-redirect
- traefik.http.routers.${STACK_NAME}-media.entrypoints=https
- traefik.http.routers.${STACK_NAME}-media.rule=Host(`${DOMAIN?Variable not set}`) && PathPrefix(`/files`)
- traefik.http.routers.${STACK_NAME}-media.service=${STACK_NAME}-media
- traefik.http.middlewares.${STACK_NAME}-media-strip.stripprefix.prefixes=/files
- traefik.http.routers.${STACK_NAME}-media.middlewares=${STACK_NAME}-media-strip
- traefik.http.routers.${STACK_NAME}-media.tls=true
- traefik.http.routers.${STACK_NAME}-media.tls.certresolver=le
- traefik.http.services.${STACK_NAME}-media.loadbalancer.server.port=80
static:
networks:
- traefik-public
deploy:
placement:
constraints:
- node.labels.${ENVIRONMENT} == true
mode: replicated
replicas: 1
update_config:
parallelism: 1
order: start-first
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.routers.${STACK_NAME}-static-http.entrypoints=http
- traefik.http.routers.${STACK_NAME}-static-http.rule=Host(`${DOMAIN?Variable not set}`) && PathPrefix(`/public`)
- traefik.http.routers.${STACK_NAME}-static-http.service=${STACK_NAME}-static
- traefik.http.routers.${STACK_NAME}-static-http.middlewares=https-redirect
- traefik.http.routers.${STACK_NAME}-static.entrypoints=https
- traefik.http.routers.${STACK_NAME}-static.rule=Host(`${DOMAIN?Variable ot set}`) && PathPrefix(`/public`)
- traefik.http.middlewares.${STACK_NAME}-static-strip.stripprefix.prefixes=/public
- traefik.http.routers.${STACK_NAME}-static.middlewares=${STACK_NAME}-static-strip
- traefik.http.routers.${STACK_NAME}-static.service=${STACK_NAME}-static
- traefik.http.routers.${STACK_NAME}-static.tls=true
- traefik.http.routers.${STACK_NAME}-static.tls.certresolver=le
- traefik.http.services.${STACK_NAME}-static.loadbalancer.server.port=80
networks:
traefik-public:
external: true
configs:
backned-config:
name: ${STACK_NAME}.env
external: true
secrets:
postgres-password:
name: ${STACK_NAME}-postgres-password
external: true
flower-password:
name: ${STACK_NAME}-flower-password
external: true