updated healthcheck with a dedicated function

This commit is contained in:
venus
2026-09-13 14:38:49 -05:00
parent acd47b80aa
commit eddbf5470e
3 changed files with 28 additions and 1 deletions
-1
View File
@@ -5,4 +5,3 @@ _site/
*.log *.log
.env .env
docker-compose.yml docker-compose.yml
sample-docker-compose.yml
+23
View File
@@ -0,0 +1,23 @@
services:
web:
build:
context: .
dockerfile: Dockerfile
args:
SITE_DOMAIN: "${SITE_DOMAIN:?Error: SITE_DOMAIN is not set. Please define SITE_DOMAIN in .env}"
SITE_URL: "${SITE_URL:-https://${SITE_DOMAIN}}"
PORT: "${PORT:-8080}"
image: river-rooks-blog:latest
container_name: river_rooks_web
restart: unless-stopped
healthcheck:
test: ["CMD", "node", "healthcheck.js"]
interval: 30s
timeout: 3s
environment:
- "SITE_DOMAIN=${SITE_DOMAIN:?Error: SITE_DOMAIN is not set. Please define SITE_DOMAIN in .env}"
- "SITE_URL=${SITE_URL:-https://${SITE_DOMAIN}}"
- "PORT=${PORT:-8080}"
ports:
- "${HOST_PORT:-${PORT:-8080}}:${PORT:-8080}"
+5
View File
@@ -0,0 +1,5 @@
const port = process.env.PORT || 8080;
fetch(`http://127.0.0.1:${port}/healthz`)
.then((res)) => process.exit(res.ok ? 0:1))
.catch(() process.exit(1));