Skip to content

Commit 9616480

Browse files
committed
feat: add health-checks for the infra services
1 parent e163155 commit 9616480

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
FROM node:22-alpine
22

3+
# Set working directory
34
WORKDIR /usr/src/app
45

5-
# Create directory with proper permissions before copying files
6-
RUN mkdir -p /usr/src/app && chown -R node:node /usr/src/app
6+
# install curl for reliable health checks and set proper ownership
7+
USER root
8+
RUN apk add --no-cache curl \
9+
&& chown -R node:node /usr/src/app
710

811
# Switch to non-root user
912
USER node
@@ -23,7 +26,6 @@ EXPOSE 3000
2326

2427
# Add health check using the API health endpoint
2528
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
26-
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/v1/__health || exit 1
29+
CMD curl --fail http://localhost:3000/api/v1/__health || exit 1
2730

2831
CMD ["npm", "run", "start"]
29-

docker-compose.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,27 @@ services:
1010
- 5432:5432
1111
volumes:
1212
- visionBoard_data:/var/lib/postgresql/data
13+
healthcheck:
14+
test: ["CMD", "pg_isready", "-U", "visionBoard", "-d", "dashboard", "-h", "127.0.0.1"]
15+
interval: 10s
16+
timeout: 5s
17+
retries: 5
18+
start_period: 10s
1319

1420
adminer:
1521
image: adminer
1622
restart: always
1723
depends_on:
18-
- db
24+
db:
25+
condition: service_healthy
1926
ports:
2027
- 8080:8080
28+
healthcheck:
29+
test: ["CMD", "pgrep", "-f", "php"]
30+
interval: 10s
31+
timeout: 5s
32+
retries: 3
33+
start_period: 5s
2134

2235
schema-dump:
2336
image: postgres:17.2

0 commit comments

Comments
 (0)