feat(tools): unified container dev setup (#65589)

This commit is contained in:
Mrugesh Mohapatra
2026-02-08 12:20:52 +05:30
committed by GitHub
parent b321f075fd
commit 46b607d84a
10 changed files with 337 additions and 148 deletions
+31
View File
@@ -0,0 +1,31 @@
# To start developing:
Wait for the container to build and start. You will see "Done. Press any key to close the terminal." in the terminal when it's ready.
Once it's running, you can start the development server:
**Option 1:** Press `Ctrl+Shift+P`, type "Run Task", select "Start Development"
**Option 2:** Open a terminal and run:
```bash
pnpm run develop
```
## Optional setup
For E2E tests:
```bash
npx playwright install chromium
```
For curriculum tests:
```bash
pnpm -F=curriculum install-puppeteer
```
## More information
For detailed setup instructions and contribution guidelines, visit:
https://contribute.freecodecamp.org/how-to-setup-freecodecamp-locally
+64 -6
View File
@@ -1,8 +1,11 @@
{
"name": "freeCodeCampDC",
"name": "freeCodeCamp",
"dockerComposeFile": "docker-compose.yml",
"service": "devcontainer",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"workspaceFolder": "/workspaces/freeCodeCamp",
"mounts": [
"source=fcc-node-modules,target=${containerWorkspaceFolder}/node_modules,type=volume"
],
"forwardPorts": [3000, 8000],
"portsAttributes": {
"3000": {
@@ -17,9 +20,64 @@
"otherPortsAttributes": {
"onAutoForward": "silent"
},
"onCreateCommand": "[ ! -f .env ] && cp sample.env .env || true",
"updateContentCommand": "pnpm install && pnpm seed",
"postAttachCommand": {
"instructions": "bash -c 'echo \"\n\n\n Start a new terminal and run \\`pnpm run develop\\` when you are ready.\n\n\n\"'"
"onCreateCommand": "sudo chown node:node node_modules && ([ ! -f .env ] && cp sample.env .env || true)",
"updateContentCommand": "pnpm install --prefer-offline",
"postCreateCommand": "rsync -a --include='*/' --include='.turbo/***' --exclude='*' /home/node/.cache/fcc/ ./ && set -a && . ./.env && set +a && until mongosh --eval 'rs.status().ok' 2>/dev/null; do sleep 1; done && pnpm seed",
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
],
"settings": {
"task.allowAutomaticTasks": "on",
"tasks": {
"version": "2.0.0",
"tasks": [
{
"label": "Start API Server",
"type": "shell",
"command": "pnpm run develop:api",
"isBackground": true,
"problemMatcher": [],
"presentation": {
"reveal": "always",
"panel": "dedicated",
"group": "develop"
}
},
{
"label": "Start Client Server",
"type": "shell",
"command": "pnpm run develop:client",
"isBackground": true,
"problemMatcher": [],
"presentation": {
"reveal": "always",
"panel": "dedicated",
"group": "develop"
}
},
{
"label": "Start Development",
"dependsOn": ["Start API Server", "Start Client Server"],
"problemMatcher": []
},
{
"label": "Open README",
"type": "shell",
"command": "code .devcontainer/README.md",
"presentation": {
"reveal": "silent",
"close": true
},
"runOptions": {
"runOn": "folderOpen"
}
}
]
}
}
}
}
}
+7 -15
View File
@@ -1,17 +1,16 @@
services:
devcontainer:
image: ghcr.io/freecodecamp/devcontainer:latest
depends_on:
- db
- setup
image: mcr.microsoft.com/devcontainers/typescript-node:22
volumes:
- ../..:/workspaces:cached
- ..:/workspaces/freeCodeCamp:cached
network_mode: service:db
command: sleep infinity
db:
image: mongo:8.0
container_name: mongodb
command: mongod --replSet rs0
restart: unless-stopped
hostname: mongodb
@@ -21,27 +20,20 @@ services:
test: ['CMD', 'mongosh', '--eval', "db.adminCommand('ping')"]
interval: 2s
retries: 5
start_period: 10s
setup:
image: mongo:8.0
depends_on:
db:
condition: service_healthy
restart: on-failure
# This will try to initiate the replica set, until it succeeds twice (i.e. until the replica set is already initialized)
restart: on-failure:5
command: >
mongosh --host mongodb:27017 --eval '
var cfg = {
rs.initiate({
_id: "rs0",
members: [
{ _id: 0, host: "mongodb:27017" }
]
};
try {
rs.initiate(cfg);
} catch (err) {
if(err.codeName !== "AlreadyInitialized") throw err;
}
members: [{ _id: 0, host: "mongodb:27017" }]
}).ok || rs.status().ok
'
volumes: