-
Notifications
You must be signed in to change notification settings - Fork 38
/
stack.yml
173 lines (160 loc) · 4.59 KB
/
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
version: "3.9"
services:
postgres:
image: postgres:13.1
networks:
- main
environment:
POSTGRES_PASSWORD: /run/secret/potgres_password
volumes:
- /data/postgres:/var/lib/postgresql/data
secrets:
- postgres_password
redis:
image: redis:alpine
volumes:
- /data/redis:/data
networks:
- main
traefik:
image: traefik:v2.3.4
ports:
- "80:80"
- "443:443"
command:
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
- "--providers.docker.swarmMode=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=traefik-public"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.letsencryptresolver.acme.httpchallenge=true"
- "--certificatesresolvers.letsencryptresolver.acme.httpchallenge.entrypoint=web"
- "--certificatesresolvers.letsencryptresolver.acme.email=your@email.com"
- "--certificatesresolvers.letsencryptresolver.acme.storage=/letsencrypt/acme.json"
volumes:
- /data/traefik:/letsencrypt
- /var/run/docker.sock:/var/run/docker.sock
networks:
- traefik-public
- main
dns:
# this may not be needed
- "8.8.8.8"
- "8.8.4.4"
deploy:
placement:
constraints:
- node.role == manager
labels:
- "traefik.enable=true"
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.entrypoints=web,websecure"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https@docker"
- "traefik.http.routers.http-catchall.service=redirect-service"
- "traefik.http.services.redirect-service.loadbalancer.server.port=80"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
backend: &backend
image: ${BACKEND_IMAGE_URI}
command:
- "gunicorn"
- "-t"
- "1000"
- "-b"
- "0.0.0.0:8000"
- "--log-level"
- "debug"
- "backend.wsgi"
networks:
- main
environment:
POSTGRES_PASSWORD: /run/secret/potgres_password
DEBUG: "0"
DJANGO_SETTINGS_MODULE: backend.settings.swarm_ec2
REDIS_SERVICE_HOST: redis
POSTGRES_SERVICE_HOST: postgres
S3_BUCKET_NAME: ${S3_BUCKET_NAME}
secrets:
- postgres_password
celery:
<<: *backend
command:
- "celery"
- "--app=backend.celery_app:app"
- "worker"
- "-Q"
- "default"
- "--concurrency=1"
- "--loglevel=INFO"
migrate:
<<: *backend
command:
- "python"
- "manage.py"
- "migrate"
- "--no-input"
deploy:
restart_policy:
condition: on-failure
web:
image: ${FRONTEND_IMAGE_URI}
networks:
- traefik-public
- main
ports:
- "8080:80"
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx-web.rule=Host(`${APPLICATION_HOST_NAME}`)"
- "traefik.http.routers.nginx-web.entrypoints=websecure"
- "traefik.http.routers.nginx-web.tls.certresolver=letsencryptresolver"
- "traefik.http.services.nginx-web.loadbalancer.server.port=80"
agent:
image: portainer/agent
environment:
# REQUIRED: Should be equal to the service name prefixed by "tasks." when
# deployed inside an overlay network
AGENT_CLUSTER_ADDR: tasks.agent
# AGENT_PORT: 9001
# LOG_LEVEL: debug
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
networks:
- agent_network
deploy:
mode: global
placement:
constraints: [node.platform.os == linux]
portainer:
image: portainer/portainer-ce:2.9.2
command: -H tcp://tasks.agent:9001 --tlsskipverify
volumes:
- /data/portainer:/data
networks:
- traefik-public
- agent_network
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.role == manager]
labels:
- "traefik.enable=true"
- "traefik.http.routers.portainer.rule=Host(`${PORTAINER_HOST_NAME}`)"
- "traefik.http.routers.portainer.entrypoints=websecure"
- "traefik.http.routers.portainer.tls=true"
- "traefik.http.services.portainer.loadbalancer.server.port=9000"
- "traefik.http.routers.portainer.service=portainer"
networks:
traefik-public:
external: true
main:
driver: overlay
agent_network:
driver: overlay
attachable: true
secrets:
postgres_password:
external: true