|
| 1 | +services: |
| 2 | + postgres: |
| 3 | + image: postgres:14-alpine |
| 4 | + environment: |
| 5 | + POSTGRES_USER: postgres |
| 6 | + POSTGRES_PASSWORD: postgres |
| 7 | + POSTGRES_DB: multisig |
| 8 | + volumes: |
| 9 | + - postgres-playwright-data:/var/lib/postgresql/data |
| 10 | + - ./docker/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh:ro |
| 11 | + healthcheck: |
| 12 | + test: ["CMD-SHELL", "pg_isready -U postgres"] |
| 13 | + interval: 5s |
| 14 | + timeout: 5s |
| 15 | + retries: 20 |
| 16 | + networks: |
| 17 | + - multisig-playwright-network |
| 18 | + |
| 19 | + app: |
| 20 | + build: |
| 21 | + context: . |
| 22 | + dockerfile: Dockerfile.ci |
| 23 | + target: app |
| 24 | + # `next build` inlines NEXT_PUBLIC_* into the client bundle, so the |
| 25 | + # browser flow needs them at build time, not just at runtime. If any of |
| 26 | + # these change in .env.playwright, rebuild the app image. |
| 27 | + args: |
| 28 | + NEXT_PUBLIC_BLOCKFROST_API_KEY_PREPROD: ${CI_BLOCKFROST_PREPROD_API_KEY:-} |
| 29 | + # Preprod currently requires this public env var even when the test |
| 30 | + # only uses network 0, so reuse the preprod key to satisfy validation. |
| 31 | + NEXT_PUBLIC_BLOCKFROST_API_KEY_MAINNET: ${CI_BLOCKFROST_PREPROD_API_KEY:-} |
| 32 | + NEXT_PUBLIC_NETWORK_ID: ${CI_NETWORK_ID:-0} |
| 33 | + environment: |
| 34 | + NODE_ENV: test |
| 35 | + NEXT_TELEMETRY_DISABLED: "1" |
| 36 | + SKIP_ENV_VALIDATION: "true" |
| 37 | + DATABASE_URL: postgresql://postgres:postgres@postgres:5432/multisig |
| 38 | + DIRECT_URL: postgresql://postgres:postgres@postgres:5432/multisig |
| 39 | + JWT_SECRET: ${CI_JWT_SECRET} |
| 40 | + CORS_ORIGINS: http://webapp:3000,http://localhost:3000 |
| 41 | + NEXT_PUBLIC_NETWORK_ID: ${CI_NETWORK_ID:-0} |
| 42 | + NEXT_PUBLIC_BLOCKFROST_API_KEY_PREPROD: ${CI_BLOCKFROST_PREPROD_API_KEY:-} |
| 43 | + NEXT_PUBLIC_BLOCKFROST_API_KEY_MAINNET: ${CI_BLOCKFROST_PREPROD_API_KEY:-} |
| 44 | + BLOCKFROST_API_KEY_PREPROD: ${CI_BLOCKFROST_PREPROD_API_KEY:-} |
| 45 | + depends_on: |
| 46 | + postgres: |
| 47 | + condition: service_healthy |
| 48 | + networks: |
| 49 | + multisig-playwright-network: |
| 50 | + # "app" matches the .app HSTS-preloaded gTLD — Chromium hard-redirects |
| 51 | + # all http://app:* to https:// before the request leaves the browser. |
| 52 | + # "webapp" is not on the preload list, so Playwright can reach it over HTTP. |
| 53 | + aliases: |
| 54 | + - webapp |
| 55 | + # Serve the production build, like docker-compose.ci.yml. `next dev` cannot |
| 56 | + # serve this app: Turbopack dev bundles @sidan-lab/whisky-js-nodejs despite |
| 57 | + # serverExternalPackages (breaking its WASM path, 500-ing every SSR page), |
| 58 | + # and webpack dev chokes on react-refresh's import.meta injection into the |
| 59 | + # CJS @harmoniclabs/cbor dist under the transpiled @meshsdk/react. |
| 60 | + command: > |
| 61 | + sh -c " |
| 62 | + echo 'Waiting for PostgreSQL to be ready...' && |
| 63 | + until pg_isready -h postgres -p 5432 -U postgres; do sleep 1; done && |
| 64 | + echo 'Running Prisma migrations...' && |
| 65 | + npx prisma migrate deploy || npx prisma db push && |
| 66 | + echo 'Starting application (production build)...' && |
| 67 | + node_modules/.bin/next start --hostname 0.0.0.0 --port 3000 |
| 68 | + " |
| 69 | + healthcheck: |
| 70 | + test: |
| 71 | + - CMD-SHELL |
| 72 | + - node -e "fetch('http://localhost:3000/api/swagger').then((r)=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))" |
| 73 | + interval: 5s |
| 74 | + timeout: 5s |
| 75 | + retries: 30 |
| 76 | + |
| 77 | + bootstrap-runner: |
| 78 | + build: |
| 79 | + context: . |
| 80 | + dockerfile: Dockerfile.ci |
| 81 | + target: base |
| 82 | + environment: |
| 83 | + NODE_ENV: test |
| 84 | + NEXT_TELEMETRY_DISABLED: "1" |
| 85 | + SKIP_ENV_VALIDATION: "true" |
| 86 | + DATABASE_URL: postgresql://postgres:postgres@postgres:5432/multisig |
| 87 | + DIRECT_URL: postgresql://postgres:postgres@postgres:5432/multisig |
| 88 | + API_BASE_URL: http://webapp:3000 |
| 89 | + CI_NETWORK_ID: ${CI_NETWORK_ID:-0} |
| 90 | + CI_NUM_REQUIRED_SIGNERS: ${CI_NUM_REQUIRED_SIGNERS:-2} |
| 91 | + CI_JWT_SECRET: ${CI_JWT_SECRET} |
| 92 | + CI_MNEMONIC_1: ${CI_MNEMONIC_1:-} |
| 93 | + CI_MNEMONIC_2: ${CI_MNEMONIC_2:-} |
| 94 | + CI_MNEMONIC_3: ${CI_MNEMONIC_3:-} |
| 95 | + CI_BLOCKFROST_PREPROD_API_KEY: ${CI_BLOCKFROST_PREPROD_API_KEY:-} |
| 96 | + CI_WALLET_TYPES: ${CI_WALLET_TYPES:-legacy,hierarchical,sdk} |
| 97 | + CI_CONTEXT_PATH: /artifacts/ci-wallet-context.json |
| 98 | + depends_on: |
| 99 | + app: |
| 100 | + condition: service_healthy |
| 101 | + networks: |
| 102 | + - multisig-playwright-network |
| 103 | + volumes: |
| 104 | + - ./ci-artifacts:/artifacts |
| 105 | + profiles: |
| 106 | + - playwright |
| 107 | + command: node .ci-dist/bootstrap.mjs |
| 108 | + |
| 109 | + playwright-runner: |
| 110 | + build: |
| 111 | + context: . |
| 112 | + dockerfile: Dockerfile.playwright |
| 113 | + # Three Chromium instances run in parallel (one per ring-transfer leg); |
| 114 | + # Docker's default 64MB /dev/shm makes Chromium crash under that load. |
| 115 | + shm_size: 1gb |
| 116 | + environment: |
| 117 | + APP_URL: http://webapp:3000 |
| 118 | + PLAYWRIGHT_WORKERS: ${PLAYWRIGHT_WORKERS:-3} |
| 119 | + CI_CONTEXT_PATH: /artifacts/ci-wallet-context.json |
| 120 | + CI_JWT_SECRET: ${CI_JWT_SECRET} |
| 121 | + CI_MNEMONIC_1: ${CI_MNEMONIC_1:-} |
| 122 | + CI_MNEMONIC_2: ${CI_MNEMONIC_2:-} |
| 123 | + CI_MNEMONIC_3: ${CI_MNEMONIC_3:-} |
| 124 | + CI_BLOCKFROST_PREPROD_API_KEY: ${CI_BLOCKFROST_PREPROD_API_KEY:-} |
| 125 | + CI_TRANSFER_LOVELACE: ${CI_TRANSFER_LOVELACE:-2000000} |
| 126 | + PLAYWRIGHT_HTML_REPORT: /artifacts/playwright-report |
| 127 | + PLAYWRIGHT_OUTPUT_DIR: /artifacts/playwright-traces |
| 128 | + depends_on: |
| 129 | + bootstrap-runner: |
| 130 | + condition: service_completed_successfully |
| 131 | + app: |
| 132 | + condition: service_healthy |
| 133 | + networks: |
| 134 | + - multisig-playwright-network |
| 135 | + volumes: |
| 136 | + - ./ci-artifacts:/artifacts |
| 137 | + # Mount e2e sources and CI framework at runtime so local edits are picked |
| 138 | + # up immediately without rebuilding the image. Docker's BuildKit layer |
| 139 | + # cache on Windows often fails to detect file changes inside COPY layers, |
| 140 | + # so this is the reliable alternative. |
| 141 | + - ./e2e:/app/e2e:ro |
| 142 | + - ./scripts/ci/framework:/app/scripts/ci/framework:ro |
| 143 | + profiles: |
| 144 | + - playwright |
| 145 | + command: npx playwright test --config=e2e/playwright.config.ts |
| 146 | + |
| 147 | +volumes: |
| 148 | + postgres-playwright-data: |
| 149 | + |
| 150 | +networks: |
| 151 | + multisig-playwright-network: |
| 152 | + driver: bridge |
0 commit comments