-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-compose-mongo.yml
129 lines (124 loc) · 4.48 KB
/
docker-compose-mongo.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
services:
mongo:
profiles:
- all
- kafka_connect_standalone
- mongo_full
- mongo
image: mongo:8
hostname: mongo
restart: ${RESTART_POLICY}
deploy:
resources:
limits:
cpus: '1'
memory: 4G
ports:
- "27017:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ADMIN_DB_USER}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ADMIN_DB_PASS:?}
MONGO_INITDB_DATABASE: admin
MONGO_DATABASE_STORAGE_COLLECTION_NAME: ${MONGO_DATABASE_STORAGE_COLLECTION_NAME}
MONGO_DATABASE_SIZE_GB: ${MONGO_DATABASE_SIZE_GB}
MONGO_DATABASE_SIZE_TARGET_PERCENT: ${MONGO_DATABASE_SIZE_TARGET_PERCENT}
MONGO_DATABASE_DELETE_THRESHOLD_PERCENT: ${MONGO_DATABASE_DELETE_THRESHOLD_PERCENT}
MONGO_DATABASE_MAX_TTL_RETENTION_SECONDS: ${MONGO_DATABASE_MAX_TTL_RETENTION_SECONDS}
MONGO_DATABASE_MIN_TTL_RETENTION_SECONDS: ${MONGO_DATABASE_MIN_TTL_RETENTION_SECONDS}
MONGO_ENABLE_STORAGE_RECORD: ${MONGO_ENABLE_STORAGE_RECORD}
MONGO_ENABLE_DYNAMIC_TTL: ${MONGO_ENABLE_DYNAMIC_TTL}
MONGO_DB_NAME: ${MONGO_DB_NAME}
MONGO_DB_KEYFILE_STRING: ${MONGO_DB_KEYFILE_STRING:?}
entrypoint:
- bash
- -c
- |
apt update
apt install -y cron gettext systemctl dos2unix
systemctl start cron
systemctl enable cron
envsubst < /data/manage-volume-cron > /etc/cron.d/manage-volume-cron
dos2unix /etc/cron.d/manage-volume-cron
chmod 644 /etc/cron.d/manage-volume-cron
systemctl restart cron
echo "$MONGO_DB_KEYFILE_STRING" > /data/keyfile.txt
chmod 400 /data/keyfile.txt
chown 999:999 /data/keyfile.txt
exec docker-entrypoint.sh $$@
command: ["mongod", "--replSet", "rs0", "--bind_ip_all", "--keyFile", "/data/keyfile.txt"]
volumes:
- mongo_data:/data/db
- ./mongo/manage-volume-cron:/data/manage-volume-cron
- ./mongo/manage_volume.js:/data/manage_volume.js
healthcheck:
test: "echo 'db.runCommand(\"ping\").ok' | mongosh --quiet --username ${MONGO_ADMIN_DB_USER} --password ${MONGO_ADMIN_DB_PASS} --authenticationDatabase admin --eval \"rs.status().ok\""
interval: 10s
timeout: 10s
retries: 10
mongo-setup:
profiles:
- all
- kafka_connect_standalone
- mongo_full
- mongo
image: mongo:8
hostname: mongo_setup
depends_on:
- mongo
restart: on-failure
deploy:
resources:
limits:
cpus: '0.5'
memory: 1G
environment:
MONGO_ADMIN_DB_USER: ${MONGO_ADMIN_DB_USER}
MONGO_ADMIN_DB_PASS: ${MONGO_ADMIN_DB_PASS:?}
MONGO_DB_NAME: ${MONGO_DB_NAME}
MONGO_READ_WRITE_USER: ${MONGO_READ_WRITE_USER}
MONGO_READ_WRITE_PASS: ${MONGO_READ_WRITE_PASS:?}
MONGO_READ_USER: ${MONGO_READ_USER}
MONGO_READ_PASS: ${MONGO_READ_PASS:?}
MONGO_EXPORTER_USERNAME: ${MONGO_EXPORTER_USERNAME}
MONGO_EXPORTER_PASSWORD: ${MONGO_EXPORTER_PASSWORD:?}
MONGO_DATA_RETENTION_SECONDS: ${MONGO_DATA_RETENTION_SECONDS}
MONGO_ASN_RETENTION_SECONDS: ${MONGO_ASN_RETENTION_SECONDS}
CONNECT_CREATE_GEOJSONCONVERTER: ${CONNECT_CREATE_GEOJSONCONVERTER}
CONNECT_CREATE_CONFLICTMONITOR: ${CONNECT_CREATE_CONFLICTMONITOR}
CONNECT_CREATE_DEDUPLICATOR: ${CONNECT_CREATE_DEDUPLICATOR}
entrypoint: ["/bin/bash", "setup_mongo.sh"]
volumes:
- ${MONGO_SETUP_SCRIPT_RELATIVE_PATH}:/setup_mongo.sh
- ${MONGO_CREATE_INDEXES_SCRIPT_RELATIVE_PATH}:/create_indexes.js
- ${MONGO_INIT_REPLICAS_SCRIPT_RELATIVE_PATH}:/init_replicas.js
mongo-express:
profiles:
- all
- mongo_full
- mongo_express
image: mongo-express:1.0.2-18
hostname: mongo-express
restart: ${RESTART_POLICY}
deploy:
resources:
limits:
cpus: '0.5'
memory: 1G
ports:
- "8002:8081"
depends_on:
- mongo
environment:
ME_CONFIG_MONGODB_ENABLE_ADMIN: "true"
ME_CONFIG_BASICAUTH_USERNAME: ${MONGO_EXPRESS_USER}
ME_CONFIG_BASICAUTH_PASSWORD: ${MONGO_EXPRESS_PASS:?}
ME_CONFIG_MONGODB_ADMINUSERNAME: ${MONGO_ADMIN_DB_USER}
ME_CONFIG_MONGODB_ADMINPASSWORD: ${MONGO_ADMIN_DB_PASS:?}
ME_CONFIG_MONGODB_URL: mongodb://${MONGO_ADMIN_DB_USER}:${MONGO_ADMIN_DB_PASS}@${MONGO_IP}:27017/?authSource=admin&directConnection=true
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8081"]
interval: 30s
timeout: 10s
retries: 4
volumes:
mongo_data: