From f4e7dcd5e846a7f2c990d457906e6748be33910d Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 7 Aug 2024 23:25:22 +0300 Subject: [PATCH] docker: Fix healthcheck & convert to TypeScript (closes #296) --- Dockerfile | 5 +++++ docker_healthcheck.js => docker_healthcheck.ts | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) rename docker_healthcheck.js => docker_healthcheck.ts (72%) diff --git a/Dockerfile b/Dockerfile index 8087af0af..339f44fd3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,11 @@ COPY server-package.json package.json # Copy TypeScript build artifacts into the original directory structure. RUN ls RUN cp -R build/src/* src/. + +# Copy the healthcheck +RUN cp build/docker_healthcheck.js . +RUN rm docker_healthcheck.ts + RUN rm -r build # Install app dependencies diff --git a/docker_healthcheck.js b/docker_healthcheck.ts similarity index 72% rename from docker_healthcheck.js rename to docker_healthcheck.ts index 9761aebe2..c11c853a4 100755 --- a/docker_healthcheck.js +++ b/docker_healthcheck.ts @@ -1,7 +1,7 @@ -const http = require("http"); -const ini = require("ini"); -const fs = require("fs"); -const dataDir = require('./src/services/data_dir'); +import http from "http"; +import ini from "ini"; +import fs from "fs"; +import dataDir from './src/services/data_dir.js'; const config = ini.parse(fs.readFileSync(dataDir.CONFIG_INI_PATH, 'utf-8')); if (config.Network.https) { @@ -10,12 +10,12 @@ if (config.Network.https) { process.exit(0); } -const port = require('./src/services/port'); -const host = require('./src/services/host'); +import port from './src/services/port.js'; +import host from './src/services/host.js'; -const options = { timeout: 2000 }; +const options: http.RequestOptions = { timeout: 2000 }; -const callback = res => { +const callback: (res: http.IncomingMessage) => void = res => { console.log(`STATUS: ${res.statusCode}`); if (res.statusCode === 200) { process.exit(0);