-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose-swarm.yaml
231 lines (219 loc) · 5.95 KB
/
docker-compose-swarm.yaml
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
version: "3.8"
x-common-env-vars: &common-env-vars
DJANGO_SUPERUSER_USERNAME: ${DJANGO_SUPERUSER_USERNAME}
DJANGO_SUPERUSER_PASSWORD: ${DJANGO_SUPERUSER_PASSWORD}
DJANGO_SUPERUSER_EMAIL: ${DJANGO_SUPERUSER_EMAIL}
APP_LOG_LEVEL: ${APP_LOG_LEVEL}
DJANGO_LOG_LEVEL: ${DJANGO_LOG_LEVEL}
DEBUG: ${DEBUG}
ALLOWED_HOSTS: ${ALLOWED_HOSTS}
CSRF_ORIGINS: ${CSRF_ORIGINS}
SESSION_COOKIE_AGE: ${SESSION_COOKIE_AGE}
SECRET_KEY: ${SECRET_KEY}
STATIC_ROOT: ${STATIC_ROOT}
MEDIA_ROOT: ${MEDIA_ROOT}
USE_TZ: ${USE_TZ}
LANGUAGE_CODE: ${LANGUAGE_CODE}
TZ: ${TZ}
DATABASE_TYPE: ${DATABASE_TYPE}
DATABASE_NAME: ${DATABASE_NAME}
DATABASE_USER: ${DATABASE_USER}
DATABASE_PASS: ${DATABASE_PASS}
DATABASE_HOST: ${DATABASE_HOST}
DATABASE_PORT: ${DATABASE_PORT}
SENTRY_URL: ${SENTRY_URL}
SENTRY_SAMPLE_RATE: ${SENTRY_SAMPLE_RATE}
SENTRY_DEBUG: ${SENTRY_DEBUG}
SENTRY_ENVIRONMENT: ${SENTRY_ENVIRONMENT}
USE_X_FORWARDED_HOST: ${USE_X_FORWARDED_HOST}
SECURE_REFERRER_POLICY: ${SECURE_REFERRER_POLICY}
REDIS_IGNORE_EXCEPTIONS: ${REDIS_IGNORE_EXCEPTIONS}
CACHE_BACKEND: ${CACHE_BACKEND}
CACHE_LOCATION: ${CACHE_LOCATION}
CELERY_BROKER_URL: ${CELERY_BROKER_URL}
CELERY_RESULT_BACKEND: ${CELERY_RESULT_BACKEND}
EMAIL_FROM_USER: ${EMAIL_FROM_USER}
EMAIL_HOST_USER: ${EMAIL_HOST_USER}
EMAIL_HOST_PASSWORD: ${EMAIL_HOST_PASSWORD}
EMAIL_HOST: ${EMAIL_HOST}
EMAIL_USE_TLS: ${EMAIL_USE_TLS}
EMAIL_PORT: ${EMAIL_PORT}
GOOGLE_SITE_PUBLIC: ${GOOGLE_SITE_PUBLIC}
GOOGLE_SITE_SECRET: ${GOOGLE_SITE_SECRET}
OAUTH_CLIENT_ID: ${OAUTH_CLIENT_ID}
OAUTH_CLIENT_SECRET: ${OAUTH_CLIENT_SECRET}
OAUTH_REDIRECT_URL: ${OAUTH_REDIRECT_URL}
SITE_URL: ${SITE_URL}
SUPER_USERS: ${SUPER_USERS}
DISCORD_WEBHOOK: ${DISCORD_WEBHOOK}
DISCORD_INVITE: ${DISCORD_INVITE}
CONTACT_FORM_TO_EMAIL: ${CONTACT_FORM_TO_EMAIL}
services:
nginx:
build:
context: nginx
image: ghcr.io/cssnr/django5-boiler-nginx:${VERSION:-latest}
deploy:
mode: global
resources:
limits:
cpus: "1.0"
memory: 32M
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik-public"
- "traefik.constraint-label=traefik-public"
- "traefik.http.routers.STACK_NAME-http.rule=Host(`${TRAEFIK_HOST:?err}`)"
- "traefik.http.routers.STACK_NAME-http.entrypoints=http"
- "traefik.http.routers.STACK_NAME-http.middlewares=https-redirect"
- "traefik.http.routers.STACK_NAME-https.rule=Host(`${TRAEFIK_HOST:?err}`)"
- "traefik.http.routers.STACK_NAME-https.entrypoints=https"
- "traefik.http.routers.STACK_NAME-https.tls=true"
- "traefik.http.services.STACK_NAME.loadbalancer.server.port=80"
- "traefik.http.services.STACK_NAME.loadbalancer.server.scheme=http"
#healthcheck:
# test: ["CMD-SHELL", "curl -sf localhost:80/health-check || exit 1"]
# interval: 10s
# timeout: 10s
# retries: 3
# start_period: 10s
volumes:
- data_dir:/data
secrets:
- source: cssnr_basic_http_auth
target: /etc/nginx/auth.users
depends_on:
- app
- flower
- redis-commander
- phpmyadmin
networks:
- traefik-public
- internal
app:
build:
context: app
image: ghcr.io/cssnr/django5-boiler-app:${VERSION:-latest}
#env_file: stack.env
environment:
<<: *common-env-vars
command: "gunicorn project.asgi:application -b 0.0.0.0:9000 -w 2 -k uvicorn.workers.UvicornWorker"
healthcheck:
test: ["CMD", "curl", "-sf", "http://localhost:9000/app-health-check/"]
interval: 1m
timeout: 10s
retries: 3
start_period: 10s
deploy:
mode: global
resources:
limits:
cpus: "2.0"
memory: 256M
volumes:
- data_dir:/data
depends_on:
- redis
networks:
- internal
worker:
image: ghcr.io/cssnr/django5-boiler-app:${VERSION:-latest}
#env_file: stack.env
environment:
<<: *common-env-vars
command: "celery -A project worker -l INFO -c 2"
deploy:
replicas: 1
resources:
limits:
cpus: "2.0"
memory: 256M
#volumes:
# - data_dir:/data
depends_on:
- redis
networks:
- internal
beat:
image: ghcr.io/cssnr/django5-boiler-app:${VERSION:-latest}
#env_file: stack.env
environment:
<<: *common-env-vars
command: "celery -A project beat -l INFO -S django"
deploy:
replicas: 1
depends_on:
- redis
- worker
networks:
- internal
redis:
image: redis:6-alpine
command: "redis-server --appendonly yes"
deploy:
replicas: 1
resources:
limits:
cpus: "1.0"
memory: 32M
volumes:
- redis_data:/data
networks:
- internal
redis-commander:
image: ghcr.io/joeferner/redis-commander:latest
environment:
- REDIS_HOSTS=local:redis:6379:0,local:redis:6379:1
- URL_PREFIX=/redis
- TRUST_PROXY=true
deploy:
replicas: 1
depends_on:
- redis
networks:
- internal
flower:
image: mher/flower:1.2
#env_file: stack.env
environment:
<<: *common-env-vars
command: "celery flower --enable_events=False --url_prefix=flower"
deploy:
replicas: 1
volumes:
- flower_data:/data
depends_on:
- app
- redis
- worker
networks:
- internal
phpmyadmin:
image: phpmyadmin:latest
environment:
- APACHE_PORT=8082
- PMA_ABSOLUTE_URI=/phpmyadmin/
- PMA_HOST=${DATABASE_HOST}
- PMA_PORT=${DATABASE_PORT}
- PMA_USER=${DATABASE_USER}
- PMA_PASSWORD=${DATABASE_PASS}
deploy:
replicas: 1
networks:
- internal
networks:
internal:
driver: overlay
traefik-public:
external: true
secrets:
cssnr_basic_http_auth:
external: true
volumes:
data_dir:
flower_data:
redis_data:
# driver_opts:
# type: none
# o: bind
# device: /data/docker/STACK_NAME