forked from smartsdk/mongo-rs-controller-swarm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-compose.yml
84 lines (77 loc) · 2.49 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
version: '3.3'
services:
mongo:
image: mongo:${MONGO_VERSION:-3.6}
# the bind_ip option is requried from MONGO Version 3.6, alternatively you can use --bind_ip_all
entrypoint: [ "/usr/bin/mongod", "--keyFile", "/run/secrets/mongo-keyfile", "--replSet", "${REPLICASET_NAME:-rs}", "--journal", "--smallfiles", "--bind_ip", "0.0.0.0"]
# ports:
# - "${MONGO_PORT:-27017}:27017"
# The usage of volume provides persistence, but may work correctly only with 1 volume per node (that's why global mode is recommended)
volumes:
- mongodata:/data/db
networks:
- backend
configs:
# to avoid changes to the original mongo image, we import the healthcheck script using configs
- mongo-healthcheck
# - source: mongo-keyfile
# target: /mongo-keyfile
# mode: 0400
secrets:
- source: mongo-keyfile
mode: 0400
# it simply checks that the client can connect to mongo. No test is run w.r.t. the cluster.
healthcheck:
test: ["CMD", "bash", "/mongo-healthcheck"]
interval: 1m
timeout: 10s
retries: 3
deploy:
mode: global
restart_policy:
condition: on-failure
update_config:
parallelism: 1
delay: 1m30s
controller:
image: tpisto/mongo-replica-ctrl:latest
volumes:
# TODO: Avoid exposing the docker socket (security issue)
- /var/run/docker.sock:/var/run/docker.sock
environment:
- OVERLAY_NETWORK_NAME=${BACKEND_NETWORK_NAME:-backend}
- MONGO_SERVICE_NAME=${STACK_NAME:-mongo}_mongo
- REPLICASET_NAME=${REPLICASET_NAME:-rs}
- MONGO_PORT=27017
- MONGO_ROOT_USERNAME=${MONGO_ROOT_USERNAME:-admin}
- MONGO_ROOT_PASSWORD=${MONGO_ROOT_PASSWORD:-password}
# - DEBUG=1 #uncomment to debug the script
entrypoint: python /src/replica_ctrl.py
networks:
- backend
depends_on:
- "mongo"
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.role==manager]
restart_policy:
condition: on-failure
configs:
# to avoid changes to the original mongo image, we import the healthcheck script using configs
mongo-healthcheck:
file: mongo-healthcheck
# mongo-keyfile:
# file: mongo-keyfile
secrets:
mongo-keyfile:
external: true
volumes:
# External true ensures that the volume is not re-created if already present
mongodata:
external: true
networks:
backend:
external:
name: ${BACKEND_NETWORK_NAME:-backend}