mirror of
https://github.com/andwati/order-service.git
synced 2026-10-20 03:04:25 +00:00
29 lines
724 B
YAML
29 lines
724 B
YAML
services:
|
|
mongo:
|
|
image: mongo:8
|
|
container_name: order-service-mongo
|
|
ports:
|
|
- "27017:27017"
|
|
volumes:
|
|
- mongo-data:/data/db
|
|
entrypoint: >
|
|
bash -c "
|
|
mongod --replSet rs0 --bind_ip_all --port 27017 &
|
|
until mongosh --port 27017 --eval 'db.runCommand({ping:1})' &>/dev/null; do
|
|
echo 'Waiting for MongoDB...'
|
|
sleep 2
|
|
done;
|
|
echo 'Initializing replica set...';
|
|
mongosh --port 27017 --eval \"
|
|
try {
|
|
rs.initiate({_id: 'rs0', members: [{_id: 0, host: 'localhost:27017'}]});
|
|
} catch (e) {
|
|
print('Replica set already initialized');
|
|
}
|
|
\";
|
|
wait"
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
mongo-data:
|