-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
68 lines (63 loc) · 1.71 KB
/
docker-compose.yml
File metadata and controls
68 lines (63 loc) · 1.71 KB
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
version: '3.8'
services:
mongodb:
image: mongo:7.0
container_name: mongodb-rs
command: ["mongod", "--replSet", "rs0", "--bind_ip_all", "--quiet"]
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
environment:
- MONGO_INITDB_DATABASE=express-server-advanced
healthcheck:
test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped
mongodb-init:
image: mongo:7.0
depends_on:
mongodb:
condition: service_healthy
restart: "no"
command: >
mongosh --host mongodb:27017 --quiet --eval "
try {
rs.initiate({
_id: 'rs0',
members: [{ _id: 0, host: 'mongodb:27017' }]
});
print('Replica set initiated');
} catch(e) {
print('Replica set already initiated');
}
"
server:
build: .
ports:
- "8080:8080"
environment:
- SERVER_NAME=Express Server
- NODE_ENV=production
- PORT=8080
- CORS_ORIGIN=http://localhost:3000
- DATABASE_URL=mongodb://mongodb:27017/express-server-advanced?replicaSet=rs0
- JWT_SECRET=your-super-secret-jwt-key-change-in-production
- JWT_EXPIRES_IN=15m
- JWT_REFRESH_SECRET=your-super-secret-refresh-key-change-in-production
- JWT_REFRESH_EXPIRES_IN=7d
depends_on:
mongodb-init:
condition: service_completed_successfully
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
volumes:
mongodb_data: