From d4f63138adcc04bdcbe9700a90bb5be55acb93dc Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 10 Mar 2026 11:29:02 -0400 Subject: [PATCH] [DevOps] Add /health endpoint and Docker HEALTHCHECK - src/routes/health/+server.ts: lightweight health endpoint returning 200 OK - Dockerfile: HEALTHCHECK hitting /health every 30s, 5s timeout, 10s start period Enables Docker/Nginx zero-downtime routing and auto-recovery. --- Dockerfile | 4 ++++ src/routes/health/+server.ts | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/routes/health/+server.ts diff --git a/Dockerfile b/Dockerfile index 03abe975..849efd71 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,4 +43,8 @@ COPY --from=builder /app/.env.production .env # SvelteKit (via adapter-node) defaults to port 3000. EXPOSE 3000 +# Healthcheck to verify the app is running +HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ + CMD node -e "fetch('http://localhost:3000/health').then(r => r.ok ? process.exit(0) : process.exit(1)).catch(() => process.exit(1))" + CMD ["node", "index.js"] diff --git a/src/routes/health/+server.ts b/src/routes/health/+server.ts new file mode 100644 index 00000000..36f425ac --- /dev/null +++ b/src/routes/health/+server.ts @@ -0,0 +1,19 @@ +import { json } from '@sveltejs/kit'; +import type { RequestHandler } from './$types'; + +/** + * Health Check Endpoint + * Used by Docker and Nginx to verify the service is running. + */ +export const GET: RequestHandler = async () => { + return json({ + status: 'healthy', + timestamp: new Date().toISOString(), + service: 'aether-app-sveltekit', + node_env: process.env.NODE_ENV || 'development' + }, { + headers: { + 'Cache-Control': 'no-cache' + } + }); +};