-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
138 lines (129 loc) · 3.91 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
version: "3.8"
services:
reverse-proxy:
image: traefik:v2.10
container_name: vaultexe-reverse-proxy
restart: always
networks:
- ${VAULTEXE_PROXY_NETWORK?}
ports:
- "80:80"
- "443:443"
labels:
# Enable Traefik
- traefik.enable=true
# Attach to the traefik-public network
- traefik.docker.network=${VAULTEXE_PROXY_NETWORK?}
# HTTP middlewares
- traefik.http.middlewares.https-redirect.redirectscheme.scheme=https
- traefik.http.middlewares.https-redirect.redirectscheme.permanent=true
command:
# Enable Docker as a provider
- --providers.docker
# Disable automatic exposure of Docker services
- --providers.docker.exposedbydefault=false
# Entrypoints ports
- --entrypoints.http.address=:80
- --entrypoints.https.address=:443
# TLS certificates resolver
- --certificatesresolvers.letsencrypt.acme.email=${LETSENCRYPT_ACME_EMAIL?}
- --certificatesresolvers.letsencrypt.acme.storage=/certificates/acme.json
- --certificatesresolvers.letsencrypt.acme.tlschallenge=true
volumes:
# Add Docker as mounted volume so that Traefik can listen to Docker services labels
# :ro means that the volume is mounted in read-only mode
- /var/run/docker.sock:/var/run/docker.sock:ro
# Mount the volume to store TLS certificates
- le-tls-certificates:/certificates
depends_on:
- backend
backend:
image: ${BACKEND_IMAGE?}
container_name: vaultexe-backend
restart: always
depends_on:
- db
- redis
env_file:
- env/.env
- server/env/.env
build:
context: ./server
dockerfile: docker/Dockerfile
networks:
- ${VAULTEXE_PROXY_NETWORK?}
ports:
- ${BACKEND_PORT?}:${BACKEND_PORT?}
labels:
# Enable Traefik
- traefik.enable=true
# Attach to the traefik-public network
- traefik.docker.network=${VAULTEXE_PROXY_NETWORK?}
# HTTP router
- traefik.http.routers.backend-http.entrypoints=http
- traefik.http.routers.backend-http.rule=Host(`${BACKEND_DOMAIN?}`)
# - traefik.http.routers.backend-http.middlewares=https-redirect
# HTTPS router
- traefik.http.routers.backend-https.entrypoints=https
- traefik.http.routers.backend-https.rule=Host(`${BACKEND_DOMAIN?}`)
- traefik.http.routers.backend-https.tls=true
- traefik.http.routers.backend-https.tls.certresolver=letsencrypt
healthcheck:
test: curl -f http://${DOMAIN}:${BACKEND_PORT}/health
interval: 1m
timeout: 10s
retries: 3
start_period: 30s
db:
image: postgres:alpine3.18
container_name: vaultexe-db
restart: always
env_file:
- env/.env
volumes:
- postgres-db:/var/lib/postgresql/data
networks:
- ${VAULTEXE_PROXY_NETWORK?}
ports:
- ${POSTGRES_PORT?}:${POSTGRES_PORT?}
redis:
image: redis:7.2-rc2-alpine
container_name: vaultexe-redis
restart: always
volumes:
- redis-data:/data
networks:
- ${VAULTEXE_PROXY_NETWORK?}
ports:
- ${REDIS_PORT?}:${REDIS_PORT?}
command:
- redis-server
- --requirepass $REDIS_PASSWORD
rq-worker:
image: ${RQ_WORKER_DOCKER_IMAGE?}
container_name: vaultexe-rq-worker
restart: always
depends_on:
- redis
- db
env_file:
- env/.env
- server/env/.env
build:
context: ./server
dockerfile: docker/Dockerfile.worker
networks:
- ${VAULTEXE_PROXY_NETWORK?}
volumes:
# Volume to store the TLS certificates
# *Constraint* : Traefik is always deployed on the same Docker node
# with the same volume containing the TLS certificates
le-tls-certificates:
# Volume to store the postgres database data
postgres-db:
# Volume to store the redis data
redis-data:
networks:
vaultexe_proxy_network:
external: false
name: ${VAULTEXE_PROXY_NETWORK?}