Skip to content

Commit 2476eac

Browse files
committed
Add mongo replicaset hack to Docker compose
1 parent c3ddb47 commit 2476eac

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

syslog/docker-compose.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ services:
3434

3535
schema-registry:
3636
image: confluentinc/cp-schema-registry:5.4.0-beta1
37-
# ports:
38-
# - 8081:8081
37+
ports:
38+
- 8081:8081
3939
container_name: syslog_schema-registry
4040
hostname: schema-registry
4141
depends_on:
@@ -137,14 +137,34 @@ services:
137137
sleep infinity
138138
139139
mongodb:
140+
# *-----------------------------*
141+
# To connect to mongoDB
142+
# docker exec --interactive --tty syslog_mongodb mongo localhost:27017
143+
# *-----------------------------*
140144
image: mongo:4.2.2
141145
container_name: syslog_mongodb
142146
hostname: mongodb
143147
ports:
144148
- "27017:27017"
145-
# environment:
146-
# MONGO_INITDB_ROOT_USERNAME: root
147-
# MONGO_INITDB_ROOT_PASSWORD: example
149+
command:
150+
- bash
151+
- -c
152+
- |
153+
# Launch mongodb
154+
mongod --replSet replSet01 --bind_ip_all &
155+
# Wait for Mongo to be available
156+
# Based on https://stackoverflow.com/questions/16542372/shell-script-check-mongod-server-is-running
157+
while : ; do
158+
mongo_status=$$(mongo --eval "db.stats()" > /dev/null; echo $$?)
159+
echo -e $$(date) " Mongo RC: " $$mongo_status " (waiting for 0)"
160+
if [ $$mongo_status -eq 0 ] ; then
161+
break
162+
fi
163+
sleep 5
164+
done
165+
# Init the replicaset
166+
mongo admin --eval "rs.initiate();"
167+
sleep infinity
148168
149169
neo4j:
150170
image: neo4j:3.5-enterprise

0 commit comments

Comments
 (0)