-
Notifications
You must be signed in to change notification settings - Fork 4
/
docker-compose.yml
105 lines (97 loc) · 3.27 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
version: "3"
services:
mongodb:
image: mongo:latest
restart: always
container_name: mongodb
ports:
- "27017:27017"
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
- MONGO_REPLICA_SET_NAME=${MONGO_REPLICA_SET_NAME}
- MONGO_CL_ADMIN_USERNAME=${MONGO_CL_ADMIN_USERNAME}
- MONGO_CL_ADMIN_PASSWORD=${MONGO_CL_ADMIN_PASSWORD}
- MONGO_REPLICA_SET_ADDR1=${MONGO_REPLICA_SET_ADDR1}
- MONGO_REPLICA_SET_ADDR2=${MONGO_REPLICA_SET_ADDR2}
- MONGO_REPLICA_SET_ADDR3=${MONGO_REPLICA_SET_ADDR3}
volumes:
- mongodb-rs-1:/data/db
- ./auth/key:/auth/key
- ./scripts/rs-init.sh:/scripts/rs-init.sh
- ./scripts/user-init.sh:/scripts/user-init.sh
entrypoint: [ "/usr/bin/mongod", "--keyFile", "/auth/key", "--bind_ip_all", "--replSet", "${MONGO_REPLICA_SET_NAME}", "--port", "27017"]
networks:
- mongo-plus-network
extra_hosts:
- "mongodb:${MONGO_REPLICA_SET_ADDR1}"
- "mongodb2:${MONGO_REPLICA_SET_ADDR2}"
- "mongodb3:${MONGO_REPLICA_SET_ADDR3}"
mongodb2:
image: mongo:latest
restart: always
container_name: mongodb2
ports:
- "27018:27018"
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
volumes:
- mongodb-rs-2:/data/db
- ./auth/key:/auth/key
entrypoint: [ "/usr/bin/mongod", "--keyFile", "/auth/key", "--bind_ip_all", "--replSet", "${MONGO_REPLICA_SET_NAME}", "--port", "27018"]
networks:
- mongo-plus-network
depends_on:
- mongodb
extra_hosts:
- "mongodb:${MONGO_REPLICA_SET_ADDR1}"
- "mongodb2:${MONGO_REPLICA_SET_ADDR2}"
- "mongodb3:${MONGO_REPLICA_SET_ADDR3}"
mongodb3:
image: mongo:latest
restart: always
container_name: mongodb3
ports:
- "27019:27019"
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
volumes:
- mongodb-rs-3:/data/db
- ./auth/key:/auth/key
entrypoint: [ "/usr/bin/mongod", "--keyFile", "/auth/key", "--bind_ip_all", "--replSet", "${MONGO_REPLICA_SET_NAME}", "--port", "27019"]
networks:
- mongo-plus-network
depends_on:
- mongodb2
extra_hosts:
- "mongodb:${MONGO_REPLICA_SET_ADDR1}"
- "mongodb2:${MONGO_REPLICA_SET_ADDR2}"
- "mongodb3:${MONGO_REPLICA_SET_ADDR3}"
mongo-express:
image: mongo-express
container_name: mongo-express
restart: 'always'
ports:
- "8081:8081"
environment:
- ME_CONFIG_BASICAUTH_USERNAME=${ME_CONFIG_BASICAUTH_USERNAME}
- ME_CONFIG_BASICAUTH_PASSWORD=${ME_CONFIG_BASICAUTH_PASSWORD}
- ME_CONFIG_MONGODB_ADMINUSERNAME=${MONGO_INITDB_ROOT_USERNAME}
- ME_CONFIG_MONGODB_ADMINPASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
- ME_CONFIG_MONGODB_SERVER=mongodb
depends_on:
- mongodb3
networks:
- mongo-plus-network
extra_hosts:
- "mongodb:${MONGO_REPLICA_SET_ADDR1}"
- "mongodb2:${MONGO_REPLICA_SET_ADDR2}"
- "mongodb3:${MONGO_REPLICA_SET_ADDR3}"
networks:
mongo-plus-network:
volumes:
mongodb-rs-1:
mongodb-rs-2:
mongodb-rs-3: