Skip to content

Commit f98eec6

Browse files
authored
Merge pull request #64 from cthit/fix-replicationSets
fixed local database
2 parents 02bee89 + ce7827a commit f98eec6

File tree

2 files changed

+57
-15
lines changed

2 files changed

+57
-15
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ yarn-error.log*
3535

3636
# typescript
3737
*.tsbuildinfo
38+
39+
/data

docker-compose.yml

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
version: "3.3"
1+
version: "3.8"
22

33
services:
4-
mongo:
5-
image: mongo
6-
container_name: mongo
7-
restart: always
8-
ports:
9-
- 27017:27017
10-
volumes:
11-
- ./data:/data/db
12-
environment:
13-
MONGO_INITDB_ROOT_USERNAME: nollkit
14-
MONGO_INITDB_ROOT_PASSWORD: nollkit
154
nextjs:
165
ports:
176
- 3000:3000
@@ -22,11 +11,62 @@ services:
2211
- images:/usr/src/app/public/bilder
2312
- next:/usr/src/app/.next
2413
environment:
25-
- DATABASE_URL=mongodb://nollkit:nollkit@mongo:27017/db?authSource=admin&retryWrites=true&w=majority
26-
env_file:
27-
- .env
14+
- DATABASE_URL=mongodb://mongo:27017/db
15+
- PASSWORD=123
16+
17+
mongo:
18+
image: mongo:7.0
19+
container_name: mongo
20+
command: ["--replSet", "rs0", "--bind_ip_all", "--port", "27017"]
21+
ports:
22+
- 27017:27017
23+
extra_hosts:
24+
- "host.docker.internal:host-gateway"
25+
healthcheck:
26+
test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'host.docker.internal:27017',priority:1},{_id:1,host:'host.docker.internal:27018',priority:0.5},{_id:2,host:'host.docker.internal:27019',priority:0.5}]}) }" | mongosh --port 27017 --quiet
27+
interval: 5s
28+
timeout: 30s
29+
start_period: 0s
30+
retries: 30
31+
volumes:
32+
- "./data/originalData:/data/db"
33+
- "./data/originalData_config:/data/configdb"
34+
35+
mongo2:
36+
image: mongo:7.0
37+
command: ["--replSet", "rs0", "--bind_ip_all", "--port", "27018"]
38+
ports:
39+
- 27018:27018
40+
extra_hosts:
41+
- "host.docker.internal:host-gateway"
42+
volumes:
43+
- "./data/mongo2_data:/data/db"
44+
- "./data/mongo2_config:/data/configdb"
45+
46+
mongo3:
47+
image: mongo:7.0
48+
command: ["--replSet", "rs0", "--bind_ip_all", "--port", "27019"]
49+
ports:
50+
- 27019:27019
51+
extra_hosts:
52+
- "host.docker.internal:host-gateway"
53+
volumes:
54+
- "./data/mongo3_data:/data/db"
55+
- "./data/mongo3_config:/data/configdb"
56+
57+
58+
2859
volumes:
2960
images:
3061
next:
62+
originalData:
63+
mongo2_data:
64+
mongo3_data:
65+
originalData_config:
66+
mongo2_config:
67+
mongo3_config:
68+
3169
networks:
3270
default:
71+
common.network:
72+
driver: bridge

0 commit comments

Comments
 (0)