diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..237714d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.gradle +.env +.git +frontend/node_modules +backend/build diff --git a/build.gradle b/build.gradle index 49d979f..f49651b 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,12 @@ tasks.register('frontendTest', Exec) { 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 { dependsOn frontendLint, frontendTest } diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml new file mode 100644 index 0000000..52d6f2d --- /dev/null +++ b/docker-compose.ci.yml @@ -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: diff --git a/docker-compose.yml b/docker-compose.yml index e8b081b..f03e50a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,6 +37,7 @@ services: condition: service_healthy volumes: - .:/app + - backend-gradle-project:/app/.gradle - gradle-cache:/root/.gradle frontend: @@ -56,3 +57,4 @@ services: volumes: pgdata: gradle-cache: + backend-gradle-project: