mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-19 10:07:46 -05: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:
|
services:
|
||||||
devcontainer:
|
devcontainer:
|
||||||
depends_on:
|
depends_on:
|
||||||
- mongo-db
|
- db
|
||||||
- mongo-setup
|
- setup
|
||||||
image: mcr.microsoft.com/devcontainers/typescript-node:22
|
image: mcr.microsoft.com/devcontainers/typescript-node:22
|
||||||
volumes:
|
volumes:
|
||||||
- ../..:/workspaces:cached
|
- ../..:/workspaces:cached
|
||||||
network_mode: service:mongo-db
|
network_mode: service:db
|
||||||
command: sleep infinity
|
command: sleep infinity
|
||||||
|
|
||||||
mongo-db:
|
db:
|
||||||
image: mongo
|
image: mongo:8.0
|
||||||
|
container_name: mongodb
|
||||||
command: mongod --replSet rs0
|
command: mongod --replSet rs0
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
hostname: mongodb
|
hostname: mongodb
|
||||||
volumes:
|
volumes:
|
||||||
- mongodb-data:/data/db
|
- db-data:/data/db
|
||||||
mongo-setup:
|
healthcheck:
|
||||||
image: mongo
|
test: ['CMD', 'mongosh', '--eval', "db.adminCommand('ping')"]
|
||||||
|
interval: 2s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
setup:
|
||||||
|
image: mongo:8.0
|
||||||
depends_on:
|
depends_on:
|
||||||
- mongo-db
|
db:
|
||||||
|
condition: service_healthy
|
||||||
restart: on-failure
|
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)
|
# 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 };'''
|
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:
|
volumes:
|
||||||
mongodb-data:
|
db-data:
|
||||||
driver: local
|
driver: local
|
||||||
|
|||||||
9
.github/workflows/e2e-third-party.yml
vendored
9
.github/workflows/e2e-third-party.yml
vendored
@@ -94,15 +94,6 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
browsers: [chromium]
|
browsers: [chromium]
|
||||||
node-version: [22]
|
node-version: [22]
|
||||||
services:
|
|
||||||
mongodb:
|
|
||||||
image: mongo:8.0
|
|
||||||
ports:
|
|
||||||
- 27017:27017
|
|
||||||
mailpit:
|
|
||||||
image: axllent/mailpit
|
|
||||||
ports:
|
|
||||||
- 1025:1025
|
|
||||||
steps:
|
steps:
|
||||||
- name: Set Action Environment Variables
|
- name: Set Action Environment Variables
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
12
.github/workflows/node.js-tests.yml
vendored
12
.github/workflows/node.js-tests.yml
vendored
@@ -141,11 +141,7 @@ jobs:
|
|||||||
cat .env
|
cat .env
|
||||||
|
|
||||||
- name: Start MongoDB
|
- name: Start MongoDB
|
||||||
uses: supercharge/mongodb-github-action@b0a1493307c4e9b82ed61f3858d606c5ff190c64 # v1.10.0
|
run: docker compose -f docker/docker-compose.yml up -d
|
||||||
with:
|
|
||||||
mongodb-version: 8.0
|
|
||||||
mongodb-replica-set: test-rs
|
|
||||||
mongodb-port: 27017
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -192,11 +188,7 @@ jobs:
|
|||||||
cat .env
|
cat .env
|
||||||
|
|
||||||
- name: Start MongoDB
|
- name: Start MongoDB
|
||||||
uses: supercharge/mongodb-github-action@b0a1493307c4e9b82ed61f3858d606c5ff190c64 # v1.10.0
|
run: docker compose -f docker/docker-compose.yml up -d
|
||||||
with:
|
|
||||||
mongodb-version: 8.0
|
|
||||||
mongodb-replica-set: test-rs
|
|
||||||
mongodb-port: 27017
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
# The api cannot connect to mongodb or mailpit via localhost from inside the
|
# The api cannot connect to mongodb or mailpit via localhost from inside the
|
||||||
# container, so we have to override these variables.
|
# container, so we have to override these variables.
|
||||||
- MONGOHQ_URL=mongodb://db:27017/freecodecamp?directConnection=true
|
- MONGOHQ_URL=mongodb://mongodb:27017/freecodecamp?replicaSet=rs0
|
||||||
- MAILHOG_HOST=mailpit
|
- MAILPIT_HOST=mailpit
|
||||||
- HOST=0.0.0.0
|
- HOST=0.0.0.0
|
||||||
ports:
|
ports:
|
||||||
- '3000:3000'
|
- '3000:3000'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: mongo
|
image: mongo:8.0
|
||||||
container_name: mongodb
|
container_name: mongodb
|
||||||
command: mongod --replSet rs0
|
command: mongod --replSet rs0
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -15,14 +15,14 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
image: mongo
|
image: mongo:8.0
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
# This will try to initiate the replica set, until it succeeds twice (i.e. until the replica set is already initialized)
|
# This will try to initiate the replica set, until it succeeds twice (i.e. until the replica set is already initialized)
|
||||||
command: >
|
command: >
|
||||||
mongosh --host db:27017 --eval '
|
mongosh --host mongodb:27017 --eval '
|
||||||
var cfg = {
|
var cfg = {
|
||||||
_id: "rs0",
|
_id: "rs0",
|
||||||
members: [
|
members: [
|
||||||
|
|||||||
Reference in New Issue
Block a user