updated healthcheck with a dedicated function
This commit is contained in:
@@ -5,4 +5,3 @@ _site/
|
||||
*.log
|
||||
.env
|
||||
docker-compose.yml
|
||||
sample-docker-compose.yml
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -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));
|
||||
Reference in New Issue
Block a user