use init sidecar

This commit is contained in:
Alex Holliday committed 2025-05-22 10:02:49 -07:00
1 parent 6d39301ca8
commit b78389f113
2 files changed
+23 -6

No files matched your search

+23 -2
View File
@@ -26,8 +26,29 @@ services:
restart: unless-stopped
mongodb:
image: mongo:4.4.18
container_name: checkmate-mongodb
restart: always
command: ["mongod", "--quiet", "--replSet", "rs0", "--bind_ip_all"]
command: ["mongod", "--replSet", "rs0", "--bind_ip_all"]
ports:
- "27017:27017"
volumes:
- ./mongo/data:/data/db
- ./mongo/init:/docker-entrypoint-initdb.d
mongo-init:
image: mongo:4.4.18
depends_on:
- mongodb
entrypoint: >
bash -c "
echo 'Waiting for MongoDB to be ready...' &&
until mongo --host mongodb --eval 'db.adminCommand(\"ping\")' > /dev/null 2>&1; do
sleep 2
done &&
echo 'MongoDB is up. Initiating replica set...' &&
mongo --host mongodb --eval '
rs.initiate({
_id: \"rs0\",
members: [{ _id: 0, host: \"mongodb:27017\" }]
})
' || echo 'Replica set may already be initialized.'
"
@@ -1,4 +0,0 @@
rs.initiate({
_id: "rs0",
members: [{ _id: 0, host: "mongodb:27017" }],
});