mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-08-31 01:14:08 +08:00
fix(devcontainer): drop the compose !reset tag (#69752)
This commit is contained in:
committed by
GitHub
parent
67d1acf323
commit
1fb1ca975f
@@ -58,15 +58,6 @@ For curriculum tests:
|
||||
pnpm -F=curriculum install-puppeteer
|
||||
```
|
||||
|
||||
## How the container is built
|
||||
|
||||
- `docker/docker-compose.yml` defines MongoDB, the replica-set initialiser, and Mailpit. Contributors who work without a container use the same file.
|
||||
- `.devcontainer/docker-compose.yml` adds the development container itself. The container and Mailpit share the database container's network namespace, so `MONGOHQ_URL` and `MAILPIT_HOST` in `sample.env` need no change, and no port is published to your machine. Do not remove `network_mode: service:db`.
|
||||
- `.devcontainer/on-create.sh` creates `.env` from `sample.env`.
|
||||
- `.devcontainer/codespace-env.sh` rewrites `HOME_LOCATION` and `API_LOCATION` to the forwarded port URLs, but only inside a Codespace, because `localhost` in a browser tab points at your own machine. It does nothing anywhere else.
|
||||
- `.devcontainer/post-create.sh` restores the Turbo cache baked into the image, runs `codespace-env.sh`, waits for MongoDB, and seeds the database. The Codespace URL rewrite belongs to `postCreateCommand`, not `onCreateCommand`, because a prebuild snapshots the container after `onCreateCommand` and would freeze the wrong hostname.
|
||||
- `docker/devcontainer/Dockerfile` builds the image that `.devcontainer/docker-compose.yml` pulls from GHCR.
|
||||
|
||||
## More information
|
||||
|
||||
For the full contribution guide, see
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
"otherPortsAttributes": { "onAutoForward": "silent" },
|
||||
"onCreateCommand": ".devcontainer/on-create.sh",
|
||||
"updateContentCommand": "pnpm install --prefer-offline",
|
||||
// post-create.sh runs codespace-env.sh. That rewrite must not move to
|
||||
// onCreateCommand: a prebuild snapshots the container after onCreateCommand
|
||||
// and would freeze the wrong hostname.
|
||||
"postCreateCommand": ".devcontainer/post-create.sh",
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
|
||||
@@ -5,6 +5,9 @@ services:
|
||||
image: ghcr.io/freecodecamp/devcontainer:latest
|
||||
volumes:
|
||||
- ..:/workspaces/freeCodeCamp:cached
|
||||
# Shares the db network namespace so MONGOHQ_URL and MAILPIT_HOST in
|
||||
# sample.env resolve on localhost. A service in that namespace cannot
|
||||
# publish a port, which is why the host ports live in a separate overlay.
|
||||
network_mode: service:db
|
||||
command: sleep infinity
|
||||
depends_on:
|
||||
@@ -15,12 +18,9 @@ services:
|
||||
mailpit:
|
||||
condition: service_started
|
||||
|
||||
db:
|
||||
ports: !reset []
|
||||
|
||||
mailpit:
|
||||
# Same namespace, for MAILPIT_HOST=localhost.
|
||||
network_mode: service:db
|
||||
ports: !reset []
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
||||
@@ -172,7 +172,7 @@ jobs:
|
||||
|
||||
- name: Start apps
|
||||
run: |
|
||||
docker compose -f docker/docker-compose.yml -f docker/docker-compose.e2e.yml up -d
|
||||
docker compose -f docker/docker-compose.yml -f docker/docker-compose.ports.yml -f docker/docker-compose.e2e.yml up -d
|
||||
pnpm run serve:client-ci &
|
||||
sleep 10
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ jobs:
|
||||
cat sample.env
|
||||
|
||||
- name: Start MongoDB
|
||||
run: docker compose -f docker/docker-compose.yml up -d
|
||||
run: docker compose -f docker/docker-compose.yml -f docker/docker-compose.ports.yml up -d
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
@@ -228,7 +228,7 @@ jobs:
|
||||
echo 'SHOW_UPCOMING_CHANGES=true' >> $GITHUB_ENV
|
||||
|
||||
- name: Start MongoDB
|
||||
run: docker compose -f docker/docker-compose.yml up -d
|
||||
run: docker compose -f docker/docker-compose.yml -f docker/docker-compose.ports.yml up -d
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Docker Compose override for E2E testing
|
||||
# Usage: docker compose -f docker/docker-compose.yml -f docker/docker-compose.e2e.yml up -d
|
||||
# Usage: docker compose -f docker/docker-compose.yml -f docker/docker-compose.ports.yml -f docker/docker-compose.e2e.yml up -d
|
||||
services:
|
||||
api:
|
||||
restart: unless-stopped
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# Host ports for the setup without a container. The dev container omits
|
||||
# this file, because a service sharing the db network namespace cannot
|
||||
# publish a port.
|
||||
services:
|
||||
db:
|
||||
ports:
|
||||
- 27017:27017
|
||||
|
||||
mailpit:
|
||||
ports:
|
||||
- '1025:1025'
|
||||
- '8025:8025'
|
||||
@@ -6,8 +6,6 @@ services:
|
||||
command: mongod --replSet rs0
|
||||
restart: unless-stopped
|
||||
hostname: mongodb
|
||||
ports:
|
||||
- 27017:27017
|
||||
volumes:
|
||||
- db-data:/data/db
|
||||
healthcheck:
|
||||
@@ -34,9 +32,6 @@ services:
|
||||
mailpit:
|
||||
image: axllent/mailpit
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- '1025:1025'
|
||||
- '8025:8025'
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
|
||||
Reference in New Issue
Block a user