Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
89 lines (84 loc) · 1.9 KB
/
Copy pathdocker-compose.yml
File metadata and controls
89 lines (84 loc) · 1.9 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
services:
mongodb:
image: mongo:7.0
container_name: mongodb-dev
ports:
- "27017:27017"
environment:
- MONGO_INITDB_DATABASE=app-database
command: ["mongod", "--replSet", "rs0", "--bind_ip_all"]
volumes:
- mongodb_data:/data/db
- mongodb_config:/data/configdb
networks:
- app-network
restart: unless-stopped
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
mongodb-setup:
image: mongo:7.0
depends_on:
mongodb:
condition: service_healthy
networks:
- app-network
command: >
mongosh --host mongodb:27017 --eval "
try {
rs.status();
print('Replica set already initialized');
} catch(e) {
print('Initializing replica set...');
rs.initiate({
_id: 'rs0',
members: [
{ _id: 0, host: 'mongodb:27017' }
]
});
print('Replica set initialized');
}
"
restart: "no"
server:
build:
context: ./server
dockerfile: Dockerfile
ports:
- "3001:3001"
environment:
- NODE_ENV=development
- PORT=3001
- CLIENT_URL=http://localhost:3000
- DATABASE_URL=mongodb://mongodb:27017/app-database?replicaSet=rs0
- SESSION_SECRET=secret
depends_on:
- mongodb-setup
networks:
- app-network
restart: unless-stopped
client:
build:
context: ./client
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
- NODE_ENV=development
- PORT=3000
- NEXT_PUBLIC_SERVER_URL=http://localhost:3001
depends_on:
- server
networks:
- app-network
restart: unless-stopped
networks:
app-network:
driver: bridge
volumes:
mongodb_data:
driver: local
mongodb_config:
driver: local