This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.prod.yaml
120 lines (107 loc) · 4.09 KB
/
docker-compose.prod.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
# Production arguments passed to both containers
x-prod-args: &prod-args
# Port that both servers will run production on
PRODUCTION_PORT: &prod-port 80
PORT: *prod-port # Duplicate this under the name that the env variable will expect. Build args will override as necessary
x-db-info: &db-args
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
# Port and URL for the DB
x-db-loc: &db-loc
POSTGRES_CONTAINER: cs3733teamqyolo.c1qiic64wt6d.us-east-2.rds.amazonaws.com
POSTGRES_PORT: &pg-port "5432"
# The environment variables will expect this to already be formed, build args will override it
POSTGRES_URL: "postgresql://postgres:postgres@cs3733teamqyolo.c1qiic64wt6d.us-east-2.rds.amazonaws.com:5432/postgres?schema=public"
# Health check for all processes
x-health-check: &health-check
interval: 30s
timeout: 30s
retries: 3
# Running containers
services:
# Traefik container, used for production routing. ALL requests will automatically be routed through here
# (hence why this is the only service with a "ports") to their appropriate destination based on the routing rules
traefik:
image: traefik:latest
command:
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
# Expose the standard HTTP port, have it automatically redirect to https
- "--entrypoints.web.address=:80"
- "--log.level=DEBUG"
ports:
- "80:80"
# Traefik requirement
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
# Mount the certificate, so that we don't try to renew the cert every time we start up
restart: always
depends_on:
frontend:
condition: service_healthy
backend:
condition: service_healthy
# Frontend (UI)
frontend:
# This is the exposed production port, so that Traefik routing can access it
expose:
- *prod-port
# Use the standard Dockerfile
# Environment allows this to work with prebuilt images
environment:
<<: *prod-args
build:
# Taken from our github repo
context: .
args:
<<: *prod-args
# Use the prod-frontend stage
target: prod-frontend
# Traefik labels
labels:
- "traefik.enable=true"
# The 443 entrypoint is the actual site
- "traefik.http.routers.frontend-https.entrypoints=web"
- "traefik.http.routers.frontend-https.rule=Host(`ec2-18-117-101-196.us-east-2.compute.amazonaws.com`)"
- "traefik.http.routers.frontend-https.tls=false"
# Despite the "loadbalancer" naming, this just describes what port this container exposes
- "traefik.http.services.frontend-https.loadbalancer.server.port=80"
image: kevinmccrudden/cs3733teamq:frontend
restart: always
healthcheck:
*health-check
# Backend (API)
backend:
# This is the exposed production port, so that Traefik routing can access it
expose:
- *prod-port
# Use the standard Dockerfile
# Environment allows this to work with prebuilt images
environment:
# Ignore the warnings, this just merges those three
<<: [ *prod-args, *db-args, *db-loc ]
build:
# Taken from our github repo
context: .
args:
# Ignore the warnings, this just merges those three
<<: [*prod-args, *db-args, *db-loc]
# This time, build the backend
target: prod-backend
# This is the same as above, except everywhere that it said frontend is now backend, and
# it requires the /api prefix on everything
labels:
- "traefik.enable=true"
# The 443 entrypoint is the actual site
- "traefik.http.routers.backend-https.entrypoints=web"
- "traefik.http.routers.backend-https.rule=Host(`ec2-18-117-101-196.us-east-2.compute.amazonaws.com`) && PathPrefix(`/api`)"
- "traefik.http.routers.backend-https.tls=false"
# Despite the "loadbalancer" naming, this just describes what port this container exposes
- "traefik.http.services.backend-https.loadbalancer.server.port=80"
image: kevinmccrudden/cs3733teamq:backend
restart: always
healthcheck:
*health-check
volumes:
acme_cert: