-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
85 lines (81 loc) · 1.65 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
version: '3.8'
services:
app:
build: .
ports:
- "3000:3000"
environment:
- DB_HOST=db
- DB_USER=postgres
- DB_PASS=password
- DB_NAME=datalouna
- REDIS_HOST=redis
depends_on:
- db
- redis
- migrate
volumes:
- .:/app # Mount project source code
- /app/node_modules # Persist node_modules within container
- /app/dist
command: npm run start
deploy:
resources:
limits:
cpus: "0.5" # Limit to 0.5 CPU
memory: "512M" # Limit to 512MB of RAM
restart: always
migrate:
build: .
depends_on:
db:
condition: service_healthy
environment:
- DB_HOST=db
- DB_USER=postgres
- DB_PASS=password
- DB_NAME=datalouna
volumes:
- .:/app
- /app/node_modules
- /app/dist
command: npx knex migrate:latest
deploy:
resources:
limits:
cpus: "0.3"
memory: "256M"
restart: on-failure
db:
image: postgres:14-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: datalouna
ports:
- "5432:5432"
volumes:
- db_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 10s
timeout: 5s
retries: 5
deploy:
resources:
limits:
cpus: "0.5"
memory: "512M"
restart: always
redis:
image: redis:6.2-alpine
ports:
- "6379:6379"
deploy:
resources:
limits:
cpus: "0.3"
memory: "256M"
restart: always
volumes:
db_data: