-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose.db-single-unix.yaml
124 lines (116 loc) · 3.5 KB
/
docker-compose.db-single-unix.yaml
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
services:
mongo1_setup:
image: mongo:${MONGO_VERSION}
container_name: mongo1_setup
ports:
- "27017:27017"
volumes:
- ${MONGO_DATA_DIR}/mongo1:/data/db
- ${MONGO_CONFIG_DIR}/mongod_noauth.conf:/etc/mongod.conf
- ${MONGO_CONFIG_DIR}/keyfile:/data/configdb/keyfile
- ${MONGO_LOGS_DIR}/mongo1:/var/log/mongodb
- ./scripts/healthcheck.sh:/healthcheck.sh:ro
command: >
mongod
--config /etc/mongod.conf
--noauth
healthcheck:
test: ["CMD-SHELL", "bash /healthcheck.sh"]
interval: 10s
timeout: 10s
retries: 3
start_period: 20s
create-users:
image: mongo:${MONGO_VERSION}
container_name: create-users
volumes:
- ./scripts/create-users.sh:/create-users.sh:ro
- ./scripts/users.json:/users.json:ro
- ${MONGO_CONFIG_DIR}/keyfile:/data/configdb/keyfile:ro
environment:
MONGO_ROOT_USERNAME: ${MONGO_ROOT_USERNAME}
MONGO_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD}
depends_on:
mongo1_setup:
condition: service_healthy
command: bash /create-users.sh
mongo1_finish_setup:
image: docker:cli
container_name: mongo1_finish_setup
volumes:
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
create-users:
condition: service_completed_successfully
command: docker stop mongo1_setup
mongo1:
image: mongo:${MONGO_VERSION}
container_name: mongo1
ports:
- "27017:27017"
volumes:
- ${MONGO_DATA_DIR}/mongo1:/data/db
- ${MONGO_CONFIG_DIR}/mongod.conf:/etc/mongod.conf
- ${MONGO_CONFIG_DIR}/keyfile:/data/configdb/keyfile # readonly режим
- ${MONGO_LOGS_DIR}/mongo1:/var/log/mongodb
- ./scripts/healthcheck.sh:/healthcheck.sh:ro
# - ./scripts/docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh:ro
command: >
mongod
--config /etc/mongod.conf
# deploy:
# resources:
# limits:
# cpus: '${MONGO_CPU_LIMIT}'
# memory: ${MONGO_MEMORY_LIMIT}
# reservations:
# cpus: '${MONGO_CPU_RESERVATION}'
# memory: ${MONGO_MEMORY_RESERVATION}
healthcheck:
test: ["CMD-SHELL", "bash /healthcheck.sh"]
interval: 10s
timeout: 10s
retries: 3
start_period: 20s
depends_on:
mongo1_finish_setup:
condition: service_completed_successfully
restart: always
mongo-init-rs:
image: mongo:${MONGO_VERSION}
container_name: mongo-init-rs
volumes:
- ./scripts/init-replica-single.sh:/init-replica.sh:ro
- ${MONGO_CONFIG_DIR}/keyfile:/data/configdb/keyfile:ro
environment:
MONGO_ROOT_USERNAME: ${MONGO_ROOT_USERNAME}
MONGO_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD}
depends_on:
mongo1:
condition: service_healthy
command: bash /init-replica.sh
update-rs:
container_name: update-rs
image: docker:cli
volumes:
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
mongo-init-rs:
condition: service_completed_successfully
command: docker restart mongo1
check-rs-ready:
image: mongo:${MONGO_VERSION}
container_name: check-rs-ready
volumes:
- ./tmp:/tmp
- ./scripts/check-rs-status.sh:/check-rs-status.sh:ro
environment:
MONGO_ROOT_USERNAME: ${MONGO_ROOT_USERNAME}
MONGO_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD}
depends_on:
update-rs:
condition: service_completed_successfully
command: bash /check-rs-status.sh
networks:
default:
name: grainjs_network