fix(ci): attach Mongo to the runner container's network
The Forgejo runner is itself a container (visible in 'docker ps' from inside the job: GITEA-ACTIONS-TASK-N_WORKFLOW-Test_JOB-playwright). '--network host' for Mongo binds to the outer Docker host's network namespace, which the runner container can't see — that's why mongodb://localhost:27017 from the Nuxt server returned ECONNREFUSED. Drop --network host. Instead, after starting Mongo, look up the runner container's own network via 'docker inspect $HOSTNAME' and attach Mongo to it. MONGODB_URI now references the container by name (mongodb://mongo-ci:27017/...).
This commit is contained in:
parent
0985f6acb1
commit
f05c1f6d40
1 changed files with 14 additions and 4 deletions
|
|
@ -22,7 +22,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: vitest
|
needs: vitest
|
||||||
env:
|
env:
|
||||||
MONGODB_URI: mongodb://localhost:27017/ghostguild-test
|
MONGODB_URI: mongodb://mongo-ci:27017/ghostguild-test
|
||||||
JWT_SECRET: ci-test-jwt-secret
|
JWT_SECRET: ci-test-jwt-secret
|
||||||
RESEND_API_KEY: re_ci_dummy_not_used
|
RESEND_API_KEY: re_ci_dummy_not_used
|
||||||
HELCIM_API_TOKEN: helcim_ci_dummy_not_used
|
HELCIM_API_TOKEN: helcim_ci_dummy_not_used
|
||||||
|
|
@ -41,7 +41,12 @@ jobs:
|
||||||
- name: Start MongoDB
|
- name: Start MongoDB
|
||||||
run: |
|
run: |
|
||||||
docker rm -f mongo-ci 2>/dev/null || true
|
docker rm -f mongo-ci 2>/dev/null || true
|
||||||
docker run -d --name mongo-ci --network host mongo:7
|
docker run -d --name mongo-ci mongo:7
|
||||||
|
# Forgejo runs each job inside its own container; attach Mongo to
|
||||||
|
# that container's network so MONGODB_URI=mongodb://mongo-ci:27017
|
||||||
|
# resolves from inside the runner.
|
||||||
|
RUNNER_NET=$(docker inspect "$HOSTNAME" --format '{{range $k,$v := .NetworkSettings.Networks}}{{$k}} {{end}}' | awk '{print $1}')
|
||||||
|
docker network connect "$RUNNER_NET" mongo-ci
|
||||||
docker ps
|
docker ps
|
||||||
- name: Wait for MongoDB
|
- name: Wait for MongoDB
|
||||||
run: timeout 30 sh -c 'until docker exec mongo-ci mongosh --quiet --eval "1" >/dev/null 2>&1; do sleep 1; done'
|
run: timeout 30 sh -c 'until docker exec mongo-ci mongosh --quiet --eval "1" >/dev/null 2>&1; do sleep 1; done'
|
||||||
|
|
@ -85,7 +90,7 @@ jobs:
|
||||||
needs: vitest
|
needs: vitest
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
env:
|
env:
|
||||||
MONGODB_URI: mongodb://localhost:27017/ghostguild-test
|
MONGODB_URI: mongodb://mongo-ci:27017/ghostguild-test
|
||||||
JWT_SECRET: ci-test-jwt-secret
|
JWT_SECRET: ci-test-jwt-secret
|
||||||
RESEND_API_KEY: re_ci_dummy_not_used
|
RESEND_API_KEY: re_ci_dummy_not_used
|
||||||
HELCIM_API_TOKEN: helcim_ci_dummy_not_used
|
HELCIM_API_TOKEN: helcim_ci_dummy_not_used
|
||||||
|
|
@ -104,7 +109,12 @@ jobs:
|
||||||
- name: Start MongoDB
|
- name: Start MongoDB
|
||||||
run: |
|
run: |
|
||||||
docker rm -f mongo-ci 2>/dev/null || true
|
docker rm -f mongo-ci 2>/dev/null || true
|
||||||
docker run -d --name mongo-ci --network host mongo:7
|
docker run -d --name mongo-ci mongo:7
|
||||||
|
# Forgejo runs each job inside its own container; attach Mongo to
|
||||||
|
# that container's network so MONGODB_URI=mongodb://mongo-ci:27017
|
||||||
|
# resolves from inside the runner.
|
||||||
|
RUNNER_NET=$(docker inspect "$HOSTNAME" --format '{{range $k,$v := .NetworkSettings.Networks}}{{$k}} {{end}}' | awk '{print $1}')
|
||||||
|
docker network connect "$RUNNER_NET" mongo-ci
|
||||||
docker ps
|
docker ps
|
||||||
- name: Wait for MongoDB
|
- name: Wait for MongoDB
|
||||||
run: timeout 30 sh -c 'until docker exec mongo-ci mongosh --quiet --eval "1" >/dev/null 2>&1; do sleep 1; done'
|
run: timeout 30 sh -c 'until docker exec mongo-ci mongosh --quiet --eval "1" >/dev/null 2>&1; do sleep 1; done'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue