Skip to content

Commit 38b19a3

Browse files
committed
docs: codespaces devcontainer
1 parent 408b015 commit 38b19a3

4 files changed

Lines changed: 174 additions & 79 deletions

File tree

src/content/docs/how-to-add-playwright-tests.mdx

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -288,32 +288,18 @@ npx playwright show-report
288288
289289
### Ensure Development Environment is Running
290290
291-
- Follow the [MongoDB installation guide](https://www.mongodb.com/basics/get-started).
291+
The Codespace devcontainer automatically sets up `.env`, installs dependencies, and seeds the database. Start the development server:
292292
293-
- Create the .env
294-
295-
```bash
296-
cp sample.env .env
297-
```
298-
299-
- Seed the database
300-
301-
```bash
302-
pnpm run seed:certified-user
303-
```
304-
305-
- Develop the server and client
306-
307-
```bash
308-
pnpm run develop
309-
```
293+
```bash
294+
pnpm run develop
295+
```
310296
311-
### Install Playwright Build Tools
297+
### Install Playwright
312298
313-
To install necessary dependencies for running Playwright run the following command:
299+
To install the browser binary needed for running Playwright tests:
314300
315301
```bash
316-
pnpm run playwright:install-build-tools
302+
npx playwright install chromium
317303
```
318304
319305
### Run the Playwright Tests on GitHub Codespaces

src/content/docs/how-to-setup-freecodecamp-locally.mdx

Lines changed: 98 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -67,57 +67,43 @@ The main repository at `https://github.com/freeCodeCamp/freeCodeCamp` is often r
6767

6868
</Aside>
6969

70-
## Cloud IDE or your own machine?
70+
## Local machine or devcontainer setup?
7171

72-
Next, you need to choose between setting up a cloud IDE or your own machine.
72+
Next, choose between a machine-native setup (recommended) or a containerized setup using devcontainers.
7373

74-
If you're looking to make a one-time contribution or want the fastest setup, use GitHub Codespaces which provides a ready-to-code environment in your web browser using devcontainers. For long-term contributions where you prefer local development, you can set up freeCodeCamp on your local machine.
74+
The **local machine setup** is the recommended approach for regular contributors. You install the prerequisites (Node.js, pnpm, MongoDB) directly on your machine, which gives you the best performance, no usage limits, and no Docker dependency. This requires a macOS or Linux environment (Windows users need [WSL2](/how-to-setup-wsl)).
7575

76-
| Feature | GitHub Codespaces | Your own machine |
77-
| --------------------------- | ------------------------------------------------------ | ------------------------------------------------ |
78-
| **Hardware requirements** | No minimum hardware requirements | Powerful minimum hardware requirements |
79-
| **Software installation** | No need to install any software | Additional software needed |
80-
| **Repository status** | Always up-to-date repository | Manual updates required |
81-
| **Setup complexity** | Easy setup with devcontainers, works in any browser | Larger download and setup time |
82-
| **Internet dependency** | Requires an internet connection to work | Minimal internet connection required once set up |
83-
| **Performance** | Consistent cloud-based performance | Depends on your machine capabilities |
84-
| **Usage limits** | 60 hours free per month for personal accounts | No usage limits |
85-
| **Environment consistency** | Identical setup for all contributors via devcontainers | May vary between different machines and OS |
76+
The **devcontainer setup** uses a pre-configured development container that works identically whether you run it locally (via VS Code + Docker) or in the cloud (via GitHub Codespaces). All dependencies, database services, and tooling are pre-installed inside the container — useful if you want a zero-config environment or you're on Windows without WSL2.
8677

87-
Once you have decided, follow the relevant tab below to continue with the setup.
88-
89-
<Tabs syncKey="environment">
90-
<TabItem label="GitHub Codespaces" icon="seti:github">
91-
92-
#### GitHub Codespaces
93-
94-
We have automated the development environment setup using devcontainers. With GitHub Codespaces, you get a consistent, ready-to-code environment that runs in your browser with all dependencies pre-installed.
78+
<Aside type='note' title='How do you decide which one?'>
9579

96-
**Launch a Codespace from your fork:**
97-
98-
<Steps>
99-
100-
1. Go to your fork at `https://github.com/YOUR_USER_NAME/freeCodeCamp`
80+
<details>
10181

102-
2. Click the green **Code** button
82+
<summary>
10383

104-
3. Select the **Codespaces** tab
84+
Read the detailed comparision here
10585

106-
4. Click **Create codespace on main**
86+
</summary>
10787

108-
Your codespace will automatically set up the development environment using our devcontainer configuration. This includes:
109-
- Installing Node.js, pnpm, and all dependencies
110-
- Setting up MongoDB
111-
- Configuring VS Code extensions
112-
- Preparing the environment variables
88+
| Feature | Local Machine (Recommended) | Devcontainer |
89+
| --------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------ |
90+
| **Platform support** | macOS and Linux only. <br/> Or with [WSL2](/how-to-setup-wsl) on Windows | Works on Windows, macOS, and Linux |
91+
| **Software installation** | Node.js, pnpm, MongoDB, and more needed | Only Docker and VS Code needed |
92+
| **Setup complexity** | Manual installation and configuration | Automated — dependencies and services pre-configured |
93+
| **Environment consistency** | May vary between different machines and OS | Identical setup for all contributors |
94+
| **Cloud option** | Local only | Can also run on GitHub Codespaces (basic tier is not sufficient) |
95+
| **Internet dependency** | Minimal once set up | Initial image pull, then minimal (local); always-on for Codespaces |
96+
| **Performance** | Depends on your machine capabilities | Depends on Docker resources allocated (local) or Codespaces tier |
97+
| **Usage limits** | No usage limits | None locally; Codespaces has 60 free hours/month |
11398

114-
5. Wait for the setup to complete (usually 2-3 minutes)
99+
</details>
115100

116-
</Steps>
101+
</Aside>
117102

118-
</TabItem>
103+
Once you have decided, follow the relevant tab below to continue with the setup.
119104

120-
<TabItem label="Local Machine" icon="laptop">
105+
<Tabs syncKey="environment">
106+
<TabItem label="Local Machine (Recommended)" icon="laptop">
121107

122108
Here is a minimum system requirement for running freeCodeCamp locally:
123109

@@ -139,7 +125,7 @@ Start by installing the prerequisite software for your operating system.
139125

140126
| Prerequisite | Version | Notes |
141127
| --------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------- |
142-
| [Node.js](http://nodejs.org) | `22.x` | We use the "Active LTS" version, see [LTS Schedule](https://nodejs.org/en/about/releases/). |
128+
| [Node.js](http://nodejs.org) | `24.x` | We use the "Active LTS" version, see [LTS Schedule](https://nodejs.org/en/about/releases/). |
143129
| [pnpm](https://pnpm.io/installation) | `10.x` | - |
144130
| [MongoDB Community Server](https://docs.mongodb.com/manual/administration/install-community/) | `8.0.x` | - |
145131
| [Docker Compose](https://docs.docker.com/compose/install/) | `2.x` | - |
@@ -265,42 +251,70 @@ You need a reference from your local clone to the `upstream` repository in addit
265251
</Steps>
266252

267253
</TabItem>
268-
</Tabs>
269254

270-
## Running freeCodeCamp
255+
<TabItem label="Devcontainer" icon="seti:docker">
271256

272-
Now that you have a copy of freeCodeCamp, you can follow these instructions to run it. This will allow you to:
257+
We have automated the development environment setup using devcontainers. The same container configuration works both locally (via VS Code + Docker) and in the cloud (via GitHub Codespaces), giving you a consistent, ready-to-code environment with all dependencies pre-installed.
273258

274-
- Preview edits to pages as they would appear on the learning platform.
275-
- Work on UI related issues and enhancements.
276-
- Debug and fix issues with the application servers and client apps.
259+
#### Option A: Run locally with VS Code and Docker
277260

278-
<Tabs syncKey="environment">
279-
<TabItem label="GitHub Codespaces" icon="seti:github">
261+
<Steps>
280262

281-
Your Codespace comes pre-configured with all dependencies installed and services like the database already running. You can start developing immediately:
263+
1. Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) and [Visual Studio Code](https://code.visualstudio.com/) if you haven't already.
282264

283-
1. In the terminal, run:
265+
2. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) in VS Code.
266+
267+
3. Clone your fork to your local machine:
284268

285269
```bash
286-
pnpm run develop
270+
git clone --depth=1 https://github.com/YOUR_USER_NAME/freeCodeCamp.git
287271
```
288272

289-
This will start both the API server and the client applications.
273+
4. Open the cloned folder in VS Code. You should see a prompt to **Reopen in Container** — click it. Alternatively, press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac), type "Reopen in Container", and select the option.
290274

291-
2. Wait for the process to complete. It can take a few minutes, you will see a notification to for the `8000` port when it's ready.
275+
5. Wait for the container to build and start. The devcontainer image has pre-cached dependencies, so this should be quick after the initial image pull. This includes:
276+
- Pre-populated pnpm dependency cache and Turbo build cache for fast installs
277+
- Setting up and seeding MongoDB
278+
- Configuring VS Code extensions (ESLint, Prettier)
279+
- Preparing the environment variables
292280

293-
3. Click on the notification to open the client application in a new browser tab.
281+
</Steps>
294282

295-
<Aside type='tip' title="Congratulations - you're all set!">
283+
#### Option B: Run on GitHub Codespaces
296284

297-
You now have a copy of freeCodeCamp's entire learning platform running in your Codespace. Go ahead and start making changes to the codebase.
285+
<Aside type='caution' title='Codespaces machine type'>
286+
287+
The default (basic) Codespaces machine type is not sufficient for running freeCodeCamp. Select at least a **4-core machine** when creating your Codespace.
298288

299289
</Aside>
300290

291+
<Steps>
292+
293+
1. Go to your fork at `https://github.com/YOUR_USER_NAME/freeCodeCamp`
294+
295+
2. Click the green **Code** button
296+
297+
3. Select the **Codespaces** tab
298+
299+
4. Click **Create codespace on main** (use the **...** menu to select a 4-core or larger machine type)
300+
301+
5. Wait for the setup to complete. The custom image has pre-cached dependencies, so this should be quick after the initial image pull.
302+
303+
</Steps>
304+
301305
</TabItem>
306+
</Tabs>
302307

303-
<TabItem label="Local Machine" icon="laptop">
308+
## Running freeCodeCamp
309+
310+
Now that you have a copy of freeCodeCamp, you can follow these instructions to run it. This will allow you to:
311+
312+
- Preview edits to pages as they would appear on the learning platform.
313+
- Work on UI related issues and enhancements.
314+
- Debug and fix issues with the application servers and client apps.
315+
316+
<Tabs syncKey="environment">
317+
<TabItem label="Local Machine (Recommended)" icon="laptop">
304318

305319
### Step 1: Set up the Environment Variable File
306320

@@ -435,6 +449,34 @@ If you have issues with the setup, check out the [troubleshooting section](/trou
435449

436450
</Aside>
437451

452+
</TabItem>
453+
454+
<TabItem label="Devcontainer" icon="seti:docker">
455+
456+
Your devcontainer comes pre-configured with all dependencies installed and services like the database already running, whether you launched it locally via VS Code + Docker or in GitHub Codespaces. You can start developing immediately:
457+
458+
#### Option 1: VS Code task
459+
460+
Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac), type "Run Task", and select **Start Development**.
461+
462+
#### Option 2: Terminal
463+
464+
In the terminal, run:
465+
466+
```bash
467+
pnpm run develop
468+
```
469+
470+
Both options will start the API server and the client application.
471+
472+
Wait for the process to complete. It can take a few minutes, you will see a notification for the `8000` port when it's ready. Click on the notification to open the client application in a new browser tab.
473+
474+
<Aside type='tip' title="Congratulations - you're all set!">
475+
476+
You now have a copy of freeCodeCamp's entire learning platform running in your devcontainer. Go ahead and start making changes to the codebase.
477+
478+
</Aside>
479+
438480
</TabItem>
439481
</Tabs>
440482

src/content/docs/troubleshooting-development-issues.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ Sometimes the service on port `8000` doesn't go live. This is common when you ar
3434

3535
If the service is not coming up on port `8000`, you can troubleshoot using these steps:
3636

37-
- **Start the server**: Run the below command in one terminal window from the root project directory (`/workspace/freeCodeCamp`).
37+
- **Start the server**: Run the below command in one terminal window from the root project directory (`/workspaces/freeCodeCamp`).
3838

3939
```bash
4040
pnpm run develop:server
4141
```
4242

43-
- **Start the client**: In another terminal window, run the below command from the client directory (`/workspace/freeCodeCamp/client`).
43+
- **Start the client**: In another terminal window, run the below command from the client directory (`/workspaces/freeCodeCamp/client`).
4444

4545
```bash
4646
pnpm run develop -- -H '0.0.0.0'

tests/mdx-tab-sync.test.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { readFileSync } from 'node:fs';
3+
import { resolve } from 'node:path';
4+
5+
type TabGroup = { syncKey: string; labels: string[] };
6+
7+
function extractTabGroups(source: string): TabGroup[] {
8+
const groups: TabGroup[] = [];
9+
const tabsRegex = /<Tabs\s+syncKey=["']([^"']+)["']>([\s\S]*?)<\/Tabs>/g;
10+
const labelRegex = /<TabItem\s+[^>]*label=["']([^"']+)["']/g;
11+
12+
let tabsMatch: RegExpExecArray | null;
13+
while ((tabsMatch = tabsRegex.exec(source)) !== null) {
14+
const [, syncKey, body] = tabsMatch;
15+
const labels: string[] = [];
16+
let labelMatch: RegExpExecArray | null;
17+
while ((labelMatch = labelRegex.exec(body)) !== null) {
18+
labels.push(labelMatch[1]);
19+
}
20+
groups.push({ syncKey, labels });
21+
}
22+
return groups;
23+
}
24+
25+
describe('MDX Tab syncKey contract', () => {
26+
const docs = [
27+
'src/content/docs/how-to-setup-freecodecamp-locally.mdx',
28+
'src/content/docs/how-to-add-playwright-tests.mdx'
29+
];
30+
31+
for (const relPath of docs) {
32+
describe(relPath, () => {
33+
const absPath = resolve(process.cwd(), relPath);
34+
const source = readFileSync(absPath, 'utf8');
35+
const groups = extractTabGroups(source);
36+
37+
it('all <Tabs> blocks sharing a syncKey use identical label sets', () => {
38+
const bySyncKey = new Map<string, string[][]>();
39+
for (const { syncKey, labels } of groups) {
40+
const list = bySyncKey.get(syncKey) ?? [];
41+
list.push(labels);
42+
bySyncKey.set(syncKey, list);
43+
}
44+
45+
for (const [syncKey, labelSets] of bySyncKey) {
46+
if (labelSets.length < 2) continue;
47+
const sorted = labelSets.map(l => [...l].sort());
48+
const first = sorted[0];
49+
for (const other of sorted.slice(1)) {
50+
expect(other, `syncKey="${syncKey}" label mismatch`).toEqual(first);
51+
}
52+
}
53+
});
54+
55+
it('no TabItem header has a trailing empty "Option N:" label', () => {
56+
expect(source).not.toMatch(/^####\s+Option\s+\d+:\s*$/m);
57+
});
58+
59+
it('every syncKey="environment" Tabs block lists Local Machine first', () => {
60+
const envGroups = groups.filter(g => g.syncKey === 'environment');
61+
for (const { labels } of envGroups) {
62+
expect(labels[0]).toBe('Local Machine (Recommended)');
63+
}
64+
});
65+
});
66+
}
67+
});

0 commit comments

Comments
 (0)