chore: add Docker CI compose, Gradle E2E task, and .dockerignore
Add infrastructure for running Playwright E2E tests in Docker and fix Gradle lock conflicts between host and container builds. Changes: - Add docker-compose.ci.yml that starts postgres, backend, frontend, and a Playwright service for CI pipelines. Uses official mcr.microsoft.com/playwright:v1.60.0-noble image. - Add backend-gradle-project named volume to docker-compose.yml so the container's .gradle/ directory is isolated from the host's. This prevents stale lock files from host Gradle builds (e.g. ./gradlew :backend:test) crashing the container's bootRun. - Add .dockerignore excluding .gradle, .env, .git, frontend/node_modules, and backend/build from the Docker build context. - Add frontendE2E Gradle task that runs npm run test:e2e:ci.
This commit is contained in:
parent
491dc99c55
commit
e05f74bd82
4 changed files with 76 additions and 0 deletions
5
.dockerignore
Normal file
5
.dockerignore
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
.gradle
|
||||||
|
.env
|
||||||
|
.git
|
||||||
|
frontend/node_modules
|
||||||
|
backend/build
|
||||||
|
|
@ -15,6 +15,12 @@ tasks.register('frontendTest', Exec) {
|
||||||
commandLine 'npm', 'run', 'test'
|
commandLine 'npm', 'run', 'test'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.register('frontendE2E', Exec) {
|
||||||
|
description = 'Run Playwright E2E tests in Docker (CI mode)'
|
||||||
|
workingDir = file("${rootProject.projectDir}/frontend")
|
||||||
|
commandLine 'npm', 'run', 'test:e2e:ci'
|
||||||
|
}
|
||||||
|
|
||||||
tasks.named('check').configure {
|
tasks.named('check').configure {
|
||||||
dependsOn frontendLint, frontendTest
|
dependsOn frontendLint, frontendTest
|
||||||
}
|
}
|
||||||
|
|
|
||||||
63
docker-compose.ci.yml
Normal file
63
docker-compose.ci.yml
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:16
|
||||||
|
container_name: bilhej-postgres-ci
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
|
POSTGRES_USER: ${POSTGRES_USER}
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
dockerfile: docker/backend.Dockerfile
|
||||||
|
context: .
|
||||||
|
container_name: bilhej-backend-ci
|
||||||
|
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}
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
- gradle-cache:/root/.gradle
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
dockerfile: docker/frontend.Dockerfile
|
||||||
|
context: .
|
||||||
|
container_name: bilhej-frontend-ci
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
|
||||||
|
playwright:
|
||||||
|
image: mcr.microsoft.com/playwright:v1.60.0-noble
|
||||||
|
container_name: bilhej-playwright
|
||||||
|
ipc: host
|
||||||
|
working_dir: /app
|
||||||
|
environment:
|
||||||
|
PLAYWRIGHT_BASE_URL: http://frontend:3000
|
||||||
|
volumes:
|
||||||
|
- ./frontend/package.json:/app/package.json
|
||||||
|
- ./frontend/package-lock.json:/app/package-lock.json
|
||||||
|
- ./frontend/playwright.config.ts:/app/playwright.config.ts
|
||||||
|
- ./frontend/e2e:/app/e2e
|
||||||
|
- ./frontend/node_modules:/app/node_modules
|
||||||
|
depends_on:
|
||||||
|
- frontend
|
||||||
|
command: >
|
||||||
|
sh -c "npm ci --ignore-scripts && npx playwright test --reporter=list"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
gradle-cache:
|
||||||
|
|
@ -37,6 +37,7 @@ services:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
|
- backend-gradle-project:/app/.gradle
|
||||||
- gradle-cache:/root/.gradle
|
- gradle-cache:/root/.gradle
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
|
|
@ -56,3 +57,4 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
pgdata:
|
pgdata:
|
||||||
gradle-cache:
|
gradle-cache:
|
||||||
|
backend-gradle-project:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue