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