-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
38 lines (34 loc) · 1.34 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
version: "3"
### Creates a named network with the default bridge driver
# The network is shared between restheart and mongodb only
# See: https://docs.docker.com/engine/userguide/networking/dockernetworks/
# See: https://docs.docker.com/engine/reference/commandline/network_create/
networks:
restheart-backend:
### Create a permanent, named data volume
# This makes much easier to identify where the mongodb data is stored on host
# See: https://docs.docker.com/engine/userguide/containers/dockervolumes/#mount-a-shared-storage-volume-as-a-data-volume
volumes:
restheart-mongo-volume:
services:
mongodb:
image: mongo:5
container_name: restheart-mongo
command: ["--bind_ip", "restheart-mongo", "--replSet", "rs0"]
environment:
MONGO_INITDB_DATABASE: restheart
volumes:
- restheart-mongo-volume:/data/db
- ./docker/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
networks:
- restheart-backend
ports:
- "27017:27017"
### Initiate MongoDB as a single node replica set
mongodb-initiate:
image: mongo:5
networks:
- restheart-backend
depends_on:
- mongodb
entrypoint: bash -c "for i in {1..100}; do mongo --host mongodb --eval 'if (!rs.status().ok) rs.initiate();' && break || sleep 2; done"