Skip to content

Commit 8a2f2d1

Browse files
authored
Merge pull request #222 from OpenPathfinder/ulises/218
2 parents 0f46e45 + 9616480 commit 8a2f2d1

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

Dockerfile

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
FROM node:22-alpine
22

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

5-
COPY package.json package-lock.json ./
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
610

7-
RUN npm install --only=production --no-cache
11+
# Switch to non-root user
12+
USER node
813

9-
COPY . .
14+
# Copy package files
15+
COPY --chown=node:node package.json package-lock.json ./
1016

11-
RUN chmod -R 755 /usr/src/app
17+
# Install dependencies
18+
RUN npm install --only=production --no-cache
1219

13-
USER node
20+
# Copy application code
21+
COPY --chown=node:node . .
1422

1523
ENV NODE_ENV=production
1624

17-
ENTRYPOINT ["node", "./visionboard.js"]
25+
EXPOSE 3000
26+
27+
# Add health check using the API health endpoint
28+
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
29+
CMD curl --fail http://localhost:3000/api/v1/__health || exit 1
30+
31+
CMD ["npm", "run", "start"]

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)