Skip to content

Commit 56e9ed9

Browse files
author
Jonathazn
committed
add healthcheck to frontend Dockerfile + prevent /health endpoint to be exposed in nginx.conf
1 parent e04bf11 commit 56e9ed9

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

Dockerfile.backend

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ COPY . .
2525
# Expose the port your backend server listens on
2626
EXPOSE 3010
2727

28+
# Healthcheck
29+
HEALTHCHECK --interval=5s --timeout=10s --retries=5 CMD ["curl", "http://127.0.0.1:3010/health"]
30+
2831
# Command to run the backend server
2932
CMD ["node", "SparkyFitnessServer.js"]

Dockerfile.frontend

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ COPY nginx.conf /etc/nginx/conf.d/default.conf
2424
# Expose port 80
2525
EXPOSE 80
2626

27+
# Healthcheck
28+
HEALTHCHECK --interval=5s --timeout=10s --retries=5 CMD ["curl", "http://127.0.0.1"]
29+
2730
# Start Nginx
2831
CMD ["nginx", "-g", "daemon off;"]

nginx.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ server {
1111
try_files $uri $uri/ /index.html;
1212
}
1313

14+
location ~ ^(/api/health/)($) {
15+
deny all;
16+
}
17+
1418
location /api/ {
1519
proxy_pass http://sparkyfitness-server:3010/;
1620
proxy_set_header Host $host;

0 commit comments

Comments
 (0)