mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(docker): consistently use DB everywhere (#62569)
This commit is contained in:
committed by
GitHub
parent
f3d2511f22
commit
97302e8886
@@ -1,33 +1,49 @@
|
||||
services:
|
||||
devcontainer:
|
||||
depends_on:
|
||||
- mongo-db
|
||||
- mongo-setup
|
||||
- db
|
||||
- setup
|
||||
image: mcr.microsoft.com/devcontainers/typescript-node:22
|
||||
volumes:
|
||||
- ../..:/workspaces:cached
|
||||
network_mode: service:mongo-db
|
||||
network_mode: service:db
|
||||
command: sleep infinity
|
||||
|
||||
mongo-db:
|
||||
image: mongo
|
||||
db:
|
||||
image: mongo:8.0
|
||||
container_name: mongodb
|
||||
command: mongod --replSet rs0
|
||||
restart: unless-stopped
|
||||
hostname: mongodb
|
||||
volumes:
|
||||
- mongodb-data:/data/db
|
||||
mongo-setup:
|
||||
image: mongo
|
||||
- db-data:/data/db
|
||||
healthcheck:
|
||||
test: ['CMD', 'mongosh', '--eval', "db.adminCommand('ping')"]
|
||||
interval: 2s
|
||||
retries: 5
|
||||
|
||||
setup:
|
||||
image: mongo:8.0
|
||||
depends_on:
|
||||
- mongo-db
|
||||
db:
|
||||
condition: service_healthy
|
||||
restart: on-failure
|
||||
entrypoint: [
|
||||
'bash',
|
||||
'-c',
|
||||
# This will try to initiate the replica set, until it succeeds twice (i.e. until the replica set is already initialized)
|
||||
'mongosh --host mongo-db:27017 --eval ''try {var cfg = { _id: "rs0", members: [{ _id: 0, host: "mongodb:27017" }] }; rs.initiate(cfg); } catch (err) { if(err.codeName !== "AlreadyInitialized") throw err };'''
|
||||
]
|
||||
# This will try to initiate the replica set, until it succeeds twice (i.e. until the replica set is already initialized)
|
||||
command: >
|
||||
mongosh --host mongodb:27017 --eval '
|
||||
var cfg = {
|
||||
_id: "rs0",
|
||||
members: [
|
||||
{ _id: 0, host: "mongodb:27017" }
|
||||
]
|
||||
};
|
||||
try {
|
||||
rs.initiate(cfg);
|
||||
} catch (err) {
|
||||
if(err.codeName !== "AlreadyInitialized") throw err;
|
||||
}
|
||||
'
|
||||
|
||||
volumes:
|
||||
mongodb-data:
|
||||
db-data:
|
||||
driver: local
|
||||
|
||||
Reference in New Issue
Block a user