From 997246d93760952e7b2fc8116a16632514794411 Mon Sep 17 00:00:00 2001 From: Varun Raj Date: Tue, 25 Mar 2025 22:03:14 +0530 Subject: [PATCH] feat: add healthcheck configuration to Docker Compose files - Introduced healthcheck settings for services in both docker-compose.yml and docker-compose-all-immich.yml. - Configured healthcheck to verify service availability by checking the health endpoint at http://localhost:3000/api/health. --- docker-compose-all-immich.yml | 6 ++++++ docker-compose.yml | 6 ++++++ src/pages/api/health.ts | 9 +++++++++ 3 files changed, 21 insertions(+) create mode 100644 src/pages/api/health.ts diff --git a/docker-compose-all-immich.yml b/docker-compose-all-immich.yml index 1dfaefc..a5e49ad 100644 --- a/docker-compose-all-immich.yml +++ b/docker-compose-all-immich.yml @@ -57,6 +57,12 @@ services: - "8001:3000" env_file: - .env + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s volumes: model-cache: diff --git a/docker-compose.yml b/docker-compose.yml index 38fd9a2..b11157e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,3 +8,9 @@ services: - "3000:3000" env_file: - .env + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s diff --git a/src/pages/api/health.ts b/src/pages/api/health.ts new file mode 100644 index 0000000..6acd1f6 --- /dev/null +++ b/src/pages/api/health.ts @@ -0,0 +1,9 @@ +import { NextApiRequest, NextApiResponse } from 'next'; + +export default function handler(req: NextApiRequest, res: NextApiResponse) { + if (req.method !== 'GET') { + return res.status(405).json({ message: 'Method not allowed' }); + } + + return res.status(200).json({ status: 'healthy' }); +} \ No newline at end of file