-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yaml
104 lines (100 loc) · 3.07 KB
/
docker-compose.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
version: "3.9"
services:
#======= Server =========#
server:
container_name: backend
restart: always
ports:
- "4001:4001"
- "4002:4002"
- "4003:4003"
- "4006:4006"
- "4010:4010"
- "5555:5555"
env_file:
- ./server/.env
build:
context: ./server
dockerfile: Dockerfile
volumes:
- ./server:/server
- /server/node_modules
- /server/prisma
depends_on:
database:
condition: service_healthy
networks:
- transcendance
#======= Database =========#
database:
image: postgres:14
container_name: db
restart: always
volumes:
- data:/var/lib/postgresql/data
ports:
- "5432:5432"
env_file:
- ./server/.env
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123
POSTGRES_DB: trans
networks:
- transcendance
#As the server and the client depends on the database. We need to launch the
#server/client being sure that database is up. Healthchek : If the command succeeds,
#the container is considered healthy. If it fails, Docker will retry
#the healthcheck every 0.5s until a maximum of 100 retries.
healthcheck:
test:
["CMD-SHELL", "psql trans -U postgres -c 'SELECT 1' || exit 1"]
interval: 0.5s
retries: 100
#======= Client =========#
client:
container_name: frontend
restart: always
ports:
- "3000:3000"
build:
context: client
dockerfile: Dockerfile
volumes: # specifies how directories in the host machine should be mounted in the container
- ./client:/app/client
- /app/node_modules #telling docker to use the app/nodes_modules that was installed in the Dockerfile when we npm i and not the one from host machine. No bind mount from the host machine!! This is an isolated bind mount
# links:
# - server
depends_on:
database:
condition: service_healthy
server:
condition: service_started
networks:
- transcendance
# nginx:
# # image: nginx
# container_name: nginx
# build:
# context: ./nginx
# dockerfile: Dockerfile
# restart: always
# ports:
# - "80:80"
# - "443:443"
# networks:
# - transcendance
# volumes:
# - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
# depends_on:
# - server
# - client
# - database
#======= Networks =========#
networks:
transcendance:
#======= Volumes =========#
volumes:
data: #internal label to identify volumes in docker compose
driver: local
name: dbase #this is the name of the volume persisted for the app on the host machine (docker host system)