bilhej/docker-compose.e2e.yml
Joakim Mörling 5abb5bc2e9
Some checks failed
CI / Lint, type check, unit tests, coverage (push) Successful in 11m41s
CI / E2E browser tests (push) Failing after 45s
fix: use host Docker socket with isolated E2E network
The per-job DinD approach failed because Forgejo Runner's service container
DNS resolution does not work when the runner itself uses DinD
(container.docker_host: tcp://dind:2375). The job container could not resolve
the 'dind' service hostname, causing docker compose to fail immediately.

New approach:

- Runner now uses container.docker_host: 'automount' which mounts the host
  Docker socket into job containers. The runner runs as root (user: 0:0)
  to access /var/run/docker.sock.

- E2E job no longer uses a 'dind' service. docker compose runs directly
  against the host Docker daemon inside the job container.

- docker-compose.e2e.yml gets a custom 'e2e' bridge network. All E2E
  containers (postgres, backend, frontend, playwright) attach only to this
  network, isolating them from other host containers (Nextcloud, Jellyfin,
  etc.). They can still reach the internet for vehicle lookup and npm.

Tradeoff: job containers can see other containers via docker ps, but they
are on an isolated network. For a single-user home server, this is the
simplest reliable configuration.
2026-05-19 18:17:01 +02:00

76 lines
1.8 KiB
YAML

networks:
e2e:
driver: bridge
services:
postgres:
image: postgres:16
container_name: bilhej-postgres-e2e
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
networks:
- e2e
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 5
backend:
build:
dockerfile: docker/backend.e2e.Dockerfile
context: .
container_name: bilhej-backend-e2e
environment:
SPRING_PROFILES_ACTIVE: docker
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
JWT_SECRET: ${JWT_SECRET}
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY}
STRIPE_WEBHOOK_SECRET: ${STRIPE_WEBHOOK_SECRET}
STRIPE_PRICE_ID: ${STRIPE_PRICE_ID}
networks:
- e2e
depends_on:
postgres:
condition: service_healthy
frontend:
build:
dockerfile: docker/frontend.e2e.Dockerfile
context: .
container_name: bilhej-frontend-e2e
networks:
- e2e
depends_on:
- backend
playwright:
build:
dockerfile: docker/playwright.e2e.Dockerfile
context: .
container_name: bilhej-playwright-e2e
ipc: host
environment:
PLAYWRIGHT_BASE_URL: http://frontend
networks:
- e2e
depends_on:
- frontend
command: >-
sh -c "
echo 'Waiting for backend...';
for i in \$(seq 1 60); do
curl -s http://backend:8080/api/vehicles/ZZZ999 > /dev/null && break;
sleep 1;
done;
echo 'Waiting for frontend...';
for i in \$(seq 1 30); do
curl -s http://frontend > /dev/null && break;
sleep 1;
done;
npx playwright test --reporter=list
"