The postgres:16 image declares a VOLUME for /var/lib/postgresql/data. Docker Compose creates an anonymous volume that persists across CI runs. When a Flyway migration file is modified, the next run sees a checksum mismatch because the old migration is already recorded in the schema_history table in the stale volume. - Add tmpfs: [/var/lib/postgresql/data] to the postgres service - This keeps data in RAM only, guaranteeing a completely fresh database on every E2E run with no persistent state between invocations Result: eliminates FlywayValidateException caused by migration checksum mismatches in CI.
78 lines
1.9 KiB
YAML
78 lines
1.9 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
|
|
tmpfs:
|
|
- /var/lib/postgresql/data
|
|
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
|
|
"
|