diff --git a/Dockerfile b/Dockerfile index 1da4ae8..fb6b1c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,6 +48,9 @@ EXPOSE 3000 ENV PORT=3000 ENV HOSTNAME="0.0.0.0" +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD curl -f http://localhost:3000/api/health || exit 1 + USER nextjs CMD ["node", "server.js"] diff --git a/app/api/health/route.ts b/app/api/health/route.ts new file mode 100644 index 0000000..23c7134 --- /dev/null +++ b/app/api/health/route.ts @@ -0,0 +1,3 @@ +import { NextResponse } from "next/server"; + +export const GET = () => NextResponse.json({ status: "healthy" }); diff --git a/docker-compose.yml b/docker-compose.yml index 41c5f4f..86f0c19 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,3 +22,9 @@ services: privileged: true restart: always init: true + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"] + interval: 30s + timeout: 10s + start_period: 30s + retries: 3