-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
179 lines (159 loc) · 5.47 KB
/
docker-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
167
168
169
170
171
172
173
174
175
176
177
178
179
services:
dev-reverse-proxy:
profiles: [dev]
image: traefik:v2.9
restart: on-failure
command:
- "--api.insecure=true"
- "--entrypoints.web.address=:80"
- "--providers.docker"
- "--providers.docker.exposedbydefault=false"
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
prod-reverse-proxy:
profiles: [prod]
image: traefik:v2.9
restart: on-failure
command:
- "--providers.docker"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--certificatesResolvers.resolver.acme.email=$ACME_EMAIL"
- "--certificatesResolvers.resolver.acme.storage=/acme/acme.json"
- "--certificatesresolvers.resolver.acme.httpchallenge=true"
- "--certificatesresolvers.resolver.acme.httpchallenge.entrypoint=web"
- "--certificatesResolvers.resolver.acme.caServer=$ACME_API"
ports:
- "80:80"
- "443:443"
volumes:
- acme:/acme
- /var/run/docker.sock:/var/run/docker.sock
dev-frontend:
profiles: [dev]
build:
context: ./frontend/
target: dev
restart: on-failure
environment:
PLATFORM_SERVER_URL: "http://backend.localhost"
PLATFORM_DEFAULT_TOKEN: "${FRONTEND_DEFAULT_TOKEN}"
volumes:
- "./frontend/src:/usr/src/app/src"
labels:
- "traefik.enable=true"
- "traefik.http.routers.frontend.rule=Host(`frontend.localhost`)"
prod-frontend:
profiles: [prod]
build:
context: ./frontend/
target: prod
args:
PLATFORM_SERVER_URL: "https://badges-api.${DOMAIN}"
PLATFORM_DEFAULT_TOKEN: "${FRONTEND_DEFAULT_TOKEN}"
restart: on-failure
labels:
- "traefik.enable=true"
- "traefik.http.routers.frontend-http.entrypoints=web"
- "traefik.http.routers.frontend-http.rule=Host(`badges.$DOMAIN`)"
- "traefik.http.routers.frontend.entrypoints=websecure"
- "traefik.http.routers.frontend.rule=Host(`badges.$DOMAIN`)"
- "traefik.http.routers.frontend.tls=true"
- "traefik.http.routers.frontend.tls.certresolver=resolver"
dev-backend:
profiles: [dev]
build:
context: ./backend/
target: dev
restart: on-failure
environment:
DB_HOST: db
DB_USER: "${DB_USER}"
DB_PASSWORD: "${DB_PASSWORD}"
DB_DATABASE: "${DB_DATABASE}"
SMTP_USERNAME: "${SMTP_USERNAME}"
SMTP_PASSWORD: "${SMTP_PASSWORD}"
SMTP_SERVER: "${SMTP_SERVER}"
SMTP_PORT: "${SMTP_PORT}"
SMTP_DEV: "${SMTP_DEV}"
MASTER_TOKEN: "${BACKEND_MASTER_TOKEN}"
PLATFORM_CLIENT_URL: "http://frontend.localhost"
volumes:
- "./backend/app:/usr/src/app/app"
depends_on:
- db
labels:
- "traefik.enable=true"
- "traefik.http.routers.backend.rule=Host(`backend.localhost`)"
- "traefik.http.routers.backend.middlewares=backend-cors@docker"
- "traefik.http.middlewares.backend-cors.headers.accesscontrolallowmethods=*"
- "traefik.http.middlewares.backend-cors.headers.accesscontrolallowheaders=*"
- "traefik.http.middlewares.backend-cors.headers.accesscontrolalloworiginlist=*"
prod-backend:
profiles: [prod]
build:
context: ./backend/
target: prod
restart: on-failure
environment:
UVICORN_WORKERS: 8
DB_HOST: db
DB_USER: "${DB_USER}"
DB_PASSWORD: "${DB_PASSWORD}"
DB_DATABASE: "${DB_DATABASE}"
SMTP_USERNAME: "${SMTP_USERNAME}"
SMTP_PASSWORD: "${SMTP_PASSWORD}"
SMTP_SERVER: "${SMTP_SERVER}"
SMTP_PORT: "${SMTP_PORT}"
SMTP_DEV: "${SMTP_DEV}"
MASTER_TOKEN: "${BACKEND_MASTER_TOKEN}"
PLATFORM_CLIENT_URL: "https://badges.$DOMAIN"
depends_on:
- db
labels:
- "traefik.enable=true"
- "traefik.http.routers.backend-http.entrypoints=web"
- "traefik.http.routers.backend-http.rule=Host(`badges-api.$DOMAIN`)"
- "traefik.http.routers.backend.entrypoints=websecure"
- "traefik.http.routers.backend.rule=Host(`badges-api.$DOMAIN`)"
- "traefik.http.routers.backend.tls=true"
- "traefik.http.routers.backend.tls.certresolver=resolver"
- "traefik.http.routers.backend.middlewares=backend-cors@docker,backend-limit@docker"
- "traefik.http.middlewares.backend-cors.headers.accesscontrolallowmethods=*"
- "traefik.http.middlewares.backend-cors.headers.accesscontrolallowheaders=*"
- "traefik.http.middlewares.backend-cors.headers.accesscontrolalloworiginlist=*"
- "traefik.http.middlewares.backend-limit.buffering.maxRequestBodyBytes=1000000"
- "traefik.http.middlewares.backend-limit.buffering.maxResponseBodyBytes=10000000"
dev-db-web:
profiles: [dev]
image: sosedoff/pgweb
restart: on-failure
environment:
DATABASE_URL: "postgres://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_DATABASE}?sslmode=disable"
depends_on:
- db
labels:
- "traefik.enable=true"
- "traefik.http.routers.db.rule=Host(`db.localhost`)"
db:
image: postgres
restart: on-failure
environment:
POSTGRES_USER: "${DB_USER}"
POSTGRES_PASSWORD: "${DB_PASSWORD}"
POSTGRES_DB: "${DB_DATABASE}"
volumes:
- "db_data:/var/lib/postgresql/data"
# healthcheck:
# test: ["CMD", "pg_isready", "-d", "${DB_DATABASE}"]
# timeout: 60s
# interval: 5s
# retries: 10
volumes:
db_data:
acme: