From cc8e4dbb77261791b57493612b6d4e6a4c3b0c8f Mon Sep 17 00:00:00 2001 From: Ruben Talstra Date: Mon, 3 Mar 2025 20:56:07 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20feat:=20Implement=20health=20che?= =?UTF-8?q?ck=20for=20backend=20service=20in=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 8 +++++++- docker-compose.yml | 6 ------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 46cabe6dff..10ecdf3fb2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN \ npm config set fetch-retries 5 ; \ npm config set fetch-retry-mintimeout 15000 ; \ npm install --no-audit; \ - # React client build + # Build React client NODE_OPTIONS="--max-old-space-size=2048" npm run frontend; \ npm prune --production; \ npm cache clean --force @@ -31,6 +31,12 @@ RUN mkdir -p /app/client/public/images /app/api/logs # Node API setup EXPOSE 3080 ENV HOST=0.0.0.0 + +# Define a health check +HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=5 \ + CMD curl -f http://localhost:3080/health || exit 1 + +# Start the backend service CMD ["npm", "run", "backend"] # Optional: for client with nginx routing diff --git a/docker-compose.yml b/docker-compose.yml index 4206d3369c..569e5dc42c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,12 +27,6 @@ services: - ./images:/app/client/public/images - ./uploads:/app/uploads - ./logs:/app/api/logs - healthcheck: - test: ["CMD", "curl", "-f", "http://api:${PORT}/health || exit 1"] - interval: 30s - timeout: 10s - retries: 5 - start_period: 10s mongodb: container_name: chat-mongodb