FROM mcr.microsoft.com/playwright:v1.61.0-jammy

WORKDIR /tests

COPY package*.json ./
RUN npm ci

COPY . .

RUN mkdir -p results test-results playwright-report

# SQLite-first execution flow:
# 1. API checks
# 2. Import test matrix into SQLite
# 3. Run Playwright; custom reporter records every test result immediately in SQLite
# 4. Export SQLite to JSON and Excel
# 5. Update original master Excel from merged JSON
# 6. Start single-page result download server on port 3000
CMD ["bash", "-lc", "node run-api-checks.js; npm run db:import-cases; npx playwright test --workers=1; npm run db:summary; npm run db:export-json; npm run db:export-excel; npm run update:excel; echo 'Tests completed. Starting result server.'; node scripts/result-server.js"]
