[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.
This commit is contained in:
Scott Idem
2026-03-10 11:29:02 -04:00
parent 01316789c6
commit d4f63138ad
2 changed files with 23 additions and 0 deletions

View File

@@ -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"]

View File

@@ -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'
}
});
};