feat: Sprint 0 — CI/CD pipeline, production Docker, health checks

CI Pipeline (.github/workflows/ci.yml):
- 5 jobs: typecheck, lint, test, build, e2e (parallel where possible)
- PostgreSQL 16 + Redis 7 service containers for test/e2e
- pnpm store, Turborepo, Playwright browser caching
- Concurrency groups cancel in-progress runs

Production Docker:
- Dockerfile.prod: 3-stage build (deps → build → runtime ~150MB)
- docker-compose.prod.yml: postgres + redis + app with health checks
- .dockerignore for fast builds
- next.config.ts: output: "standalone" for minimal runtime

Health Check Endpoints:
- GET /api/health — liveness probe (200 OK, no deps)
- GET /api/ready — readiness probe (postgres + redis connectivity)

Documentation:
- docs/ci-cd-manual.md — full pipeline manual with troubleshooting
- plan.md — Product Owner strategic plan (bottlenecks, growth, automation)

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
2026-03-19 20:33:18 +01:00
parent c02f453679
commit 0d78fe1770
9 changed files with 1070 additions and 210 deletions
+11
View File
@@ -0,0 +1,11 @@
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
export const runtime = "nodejs";
export function GET() {
return NextResponse.json({
status: "ok",
timestamp: new Date().toISOString(),
});
}
+76
View File
@@ -0,0 +1,76 @@
import { NextResponse } from "next/server";
import { prisma } from "@planarchy/db";
import { createConnection } from "net";
export const dynamic = "force-dynamic";
export const runtime = "nodejs";
const REDIS_URL = process.env["REDIS_URL"] ?? "redis://localhost:6380";
async function checkPostgres(): Promise<"ok" | "error"> {
try {
await prisma.$queryRaw`SELECT 1`;
return "ok";
} catch {
return "error";
}
}
/**
* Lightweight Redis PING check using a raw TCP socket.
* Avoids importing ioredis (which is only a dependency of @planarchy/api).
*/
async function checkRedis(): Promise<"ok" | "error"> {
return new Promise((resolve) => {
try {
const url = new URL(REDIS_URL);
const host = url.hostname || "localhost";
const port = parseInt(url.port || "6379", 10);
const timeout = 3000;
const socket = createConnection({ host, port }, () => {
// Send Redis PING command using RESP protocol
socket.write("*1\r\n$4\r\nPING\r\n");
});
socket.setTimeout(timeout);
socket.on("data", (data) => {
const response = data.toString();
socket.destroy();
// Redis responds with +PONG\r\n
resolve(response.includes("PONG") ? "ok" : "error");
});
socket.on("timeout", () => {
socket.destroy();
resolve("error");
});
socket.on("error", () => {
socket.destroy();
resolve("error");
});
} catch {
resolve("error");
}
});
}
export async function GET() {
const [postgres, redis] = await Promise.all([
checkPostgres(),
checkRedis(),
]);
const allHealthy = postgres === "ok" && redis === "ok";
return NextResponse.json(
{
status: allHealthy ? "ready" : "not_ready",
postgres,
redis,
},
{ status: allHealthy ? 200 : 503 },
);
}