🚀 feat: Implement health check for backend service in Dockerfile

This commit is contained in:
Ruben Talstra 2025-03-03 20:56:07 +01:00
parent be060cbfb7
commit cc8e4dbb77
No known key found for this signature in database
GPG key ID: 2A5A7174A60F3BEA
2 changed files with 7 additions and 7 deletions

View file

@ -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

View file

@ -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