From 78674897270d58a7086c6c7ccefcc44a5fe9fbf6 Mon Sep 17 00:00:00 2001 From: Saqib Ahmed Date: Fri, 14 Mar 2025 20:24:17 +0500 Subject: [PATCH] Add curl in docker image for native healthchecks (#4170) * Add curl in docker image for native healthchecks Fixes this issue: https://github.com/FlowiseAI/Flowise/issues/4126 * fix: add container-native healthcheck - Added curl utility in dockerfile - Added healthcheck configuration in docker compose * fix: exclude ping endpoint from logging --- Dockerfile | 4 ++++ docker/Dockerfile | 2 +- docker/docker-compose.yml | 6 ++++++ packages/server/src/utils/logger.ts | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index dfbf58d1..a824b7f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,10 @@ RUN apk add --no-cache build-base cairo-dev pango-dev # Install Chromium RUN apk add --no-cache chromium +# Install curl for container-level health checks +# Fixes: https://github.com/FlowiseAI/Flowise/issues/4126 +RUN apk add --no-cache curl + #install PNPM globaly RUN npm install -g pnpm diff --git a/docker/Dockerfile b/docker/Dockerfile index 762e3d29..82a55d6a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -13,7 +13,7 @@ RUN npm install -g flowise FROM node:20-alpine # Install runtime dependencies -RUN apk add --no-cache chromium git python3 py3-pip make g++ build-base cairo-dev pango-dev +RUN apk add --no-cache chromium git python3 py3-pip make g++ build-base cairo-dev pango-dev curl # Set the environment variable for Puppeteer to find Chromium ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 42b81bab..a9bda9e2 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -49,6 +49,12 @@ services: - REDIS_CA=${REDIS_CA} ports: - '${PORT}:${PORT}' + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:${PORT}/api/v1/ping"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 30s volumes: - ~/.flowise:/root/.flowise entrypoint: /bin/sh -c "sleep 3; flowise start" diff --git a/packages/server/src/utils/logger.ts b/packages/server/src/utils/logger.ts index c49670aa..4d13e789 100644 --- a/packages/server/src/utils/logger.ts +++ b/packages/server/src/utils/logger.ts @@ -138,7 +138,7 @@ const logger = createLogger({ }) export function expressRequestLogger(req: Request, res: Response, next: NextFunction): void { - const unwantedLogURLs = ['/api/v1/node-icon/', '/api/v1/components-credentials-icon/'] + const unwantedLogURLs = ['/api/v1/node-icon/', '/api/v1/components-credentials-icon/', '/api/v1/ping'] if (/\/api\/v1\//i.test(req.url) && !unwantedLogURLs.some((url) => new RegExp(url, 'i').test(req.url))) { const fileLogger = createLogger({ format: combine(timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), format.json(), errors({ stack: true })),