From 15b1b89f4fbff605e00d4d6d8bb3041d3f2e4728 Mon Sep 17 00:00:00 2001 From: Alan Grainger Date: Thu, 31 Oct 2024 19:17:58 +0100 Subject: [PATCH] Change Node image to lts-slim --- Dockerfile | 2 +- docker-compose.yml | 2 +- healthcheck.js | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 healthcheck.js diff --git a/Dockerfile b/Dockerfile index d1c09e0..baa5613 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:lts-alpine +FROM node:lts-slim WORKDIR /app diff --git a/docker-compose.yml b/docker-compose.yml index 8176559..c0dbeea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,6 +10,6 @@ services: env_file: - .env healthcheck: - test: ([ "$(wget -qO- ${PROXY_PUBLIC_URL}/healthcheck)" = "ok" ] && exit 0) || exit 1 + test: node /app/healthcheck.js interval: 120s start_period: 5s diff --git a/healthcheck.js b/healthcheck.js new file mode 100644 index 0000000..ce5e962 --- /dev/null +++ b/healthcheck.js @@ -0,0 +1,10 @@ +(async () => { + require('dotenv').config() + try { + const res = await fetch(process.env.PROXY_PUBLIC_URL + '/healthcheck') + if (await res.text() === 'ok') { + process.exit(0) + } + } catch (e) { } + process.exit(1) +})()