-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompose.yml
executable file
·166 lines (158 loc) · 5.44 KB
/
compose.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
version: "3.8"
networks:
app_net:
name: app_net
external: true
web_net:
name: web_net
external: true
volumes:
vote_db_data:
name: vote_db_data
traefik-acme:
name: traefik-acme
services:
traefik:
image: traefik:v2.10.4
restart: ${RESTART_POLICY}
container_name: traefik-${HOSTNAME}
hostname: traefik
command:
- "--log.level=ERROR"
- "--log.filepath=/log-file.log"
- "--log.format=json"
- "--api=true"
- "--ping=true"
- "--accesslog=true"
- "--accesslog.fields.names.StartUTC=drop"
- "--accesslog.bufferingsize=250"
- "--api.insecure=true"
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=web_net"
- "--entrypoints.http.address=:80"
- "--entrypoints.https.address=:443"
- "--metrics.prometheus=true"
- "--entryPoints.metrics.address=:8082"
- "--metrics.prometheus.entryPoint=metrics"
- "--certificatesresolvers.mycert.acme.email=${ACME_EMAIL}"
- "--certificatesresolvers.mycert.acme.storage=/acme/acme.json"
- "--certificatesresolvers.mycert.acme.tlschallenge=true"
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- traefik-acme:/acme
networks:
- web_net
labels:
- "traefik.enable=true"
- "traefik.docker.network=web_net"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(`${TRA_SUB}.${DOMAIN_ADDRESS}`)"
- "traefik.http.middlewares.web-auth.basicauth.users=${WEB_AUTH_USER}:${WEB_AUTH_PASS}"
- "traefik.http.routers.traefik.middlewares=https-redirect"
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host(`${TRA_SUB}.${DOMAIN_ADDRESS}`)"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.options=default"
- "traefik.http.routers.traefik-secure.middlewares=web-auth"
- "traefik.http.routers.traefik-secure.tls.certresolver=mycert"
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
vote:
image: ${REPOSITORY_NAME}/${IMAGE_DIRECTORY_NAME}/vote:${VERSION}
container_name: vote-${HOSTNAME}
hostname: vote-${HOSTNAME}
restart: ${RESTART_POLICY}
command: python app.py
depends_on:
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
networks:
- web_net
- app_net
labels:
- "traefik.enable=true"
- "traefik.docker.network=web_net"
- "traefik.http.routers.vote.entrypoints=http"
- "traefik.http.routers.vote.rule=Host(`${VOTE_SUB}.${DOMAIN_ADDRESS}`)"
- "traefik.http.routers.vote.middlewares=https-redirect"
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.vote-secure.entrypoints=https"
- "traefik.http.routers.vote-secure.rule=Host(`${VOTE_SUB}.${DOMAIN_ADDRESS}`)"
- "traefik.http.routers.vote-secure.tls=true"
- "traefik.http.routers.vote-secure.tls.certresolver=mycert"
- "traefik.http.services.vote.loadbalancer.server.port=80"
result:
image: ${REPOSITORY_NAME}/${IMAGE_DIRECTORY_NAME}/result:${VERSION}
container_name: result-${HOSTNAME}
hostname: result-${HOSTNAME}
restart: ${RESTART_POLICY}
entrypoint: nodemon server.js
depends_on:
db:
condition: service_healthy
networks:
- web_net
- app_net
labels:
- "traefik.enable=true"
- "traefik.docker.network=web_net"
- "traefik.http.routers.result.entrypoints=http"
- "traefik.http.routers.result.rule=Host(`${RESULT_SUB}.${DOMAIN_ADDRESS}`)"
- "traefik.http.routers.result.middlewares=https-redirect"
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.result-secure.entrypoints=https"
- "traefik.http.routers.result-secure.rule=Host(`${RESULT_SUB}.${DOMAIN_ADDRESS}`)"
- "traefik.http.routers.result-secure.tls=true"
- "traefik.http.routers.result-secure.tls.certresolver=mycert"
- "traefik.http.services.result.loadbalancer.server.port=80"
worker:
image: ${REPOSITORY_NAME}/${IMAGE_DIRECTORY_NAME}/worker:${VERSION}
container_name: worker-${HOSTNAME}
hostname: worker-${HOSTNAME}
restart: ${RESTART_POLICY}
depends_on:
redis:
condition: service_healthy
db:
condition: service_healthy
networks:
- app_net
redis:
image: redis:alpine
container_name: redis-${HOSTNAME}
hostname: redis-${HOSTNAME}
restart: ${RESTART_POLICY}
healthcheck:
test: ['CMD-SHELL', 'redis-cli ping | grep PONG']
interval: 5s
timeout: 3s
retries: 5
networks:
- app_net
db:
image: postgres:15-alpine
container_name: postgresql-${HOSTNAME}
hostname: postgresql-${HOSTNAME}
restart: ${RESTART_POLICY}
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
volumes:
- vote_db_data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready']
interval: 10s
timeout: 5s
retries: 5
networks:
- app_net