From 9d4ace8ea55d6410df0cca90705aed163f4829a1 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Sun, 20 Jul 2025 12:40:07 +0200 Subject: [PATCH] chore: print build date when started via docker Docker updates can be a bit confusing so this should help users know if they're up-to-date. --- Dockerfile | 1 + src/index.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ec346634..45f00f80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,5 +7,6 @@ WORKDIR /app RUN npm i --omit=dev RUN npm run build +RUN date '+%d %B %Y' > BUILD_DATE ENTRYPOINT ["/app/docker-entrypoint.sh"] diff --git a/src/index.ts b/src/index.ts index 6bd70f7c..4887db86 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,17 +18,23 @@ logger.info("Starting up..."); // Proceed with normal startup: bring up config watcher service, validate config, connect to MongoDB, and finally start listening for HTTP. import mongoose from "mongoose"; +import path from "path"; import { JSONStringify } from "json-with-bigint"; import { startWebServer } from "@/src/services/webService"; - import { validateConfig } from "@/src/services/configWatcherService"; import { updateWorldStateCollections } from "@/src/services/worldStateService"; +import { repoDir } from "@/src/helpers/pathHelper"; -// Patch JSON.stringify to work flawlessly with Bigints. -JSON.stringify = JSONStringify; +JSON.stringify = JSONStringify; // Patch JSON.stringify to work flawlessly with Bigints. validateConfig(); +fs.readFile(path.join(repoDir, "BUILD_DATE"), "utf-8", (err, data) => { + if (!err) { + logger.info(`Docker image was built on ${data.trim()}`); + } +}); + mongoose .connect(config.mongodbUrl) .then(() => { -- 2.47.2