From 70aa3992f814ef2434cf22a445c391e0f4f1b4fc Mon Sep 17 00:00:00 2001 From: corgifist Date: Mon, 28 Jul 2025 19:18:49 +0300 Subject: [PATCH] trying to get git commit hash to work --- next.config.ts | 7 +++++++ src/Dockerfile | 3 +++ 2 files changed, 10 insertions(+) diff --git a/next.config.ts b/next.config.ts index 12cecbe..5f84223 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,6 +2,13 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { output: "standalone", + generateBuildId: () => { + if (process.env.NODE_ENV === "development") return "development server"; + if (!process.env.GIT_COMMIT) return "git commit hash is unavailable"; + const hash = process.env.GIT_COMMIT; + if (!hash || hash.trim().length == 0) return "empty git commit hash"; + return hash; + } }; export default nextConfig; diff --git a/src/Dockerfile b/src/Dockerfile index af50048..f4f5f00 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -35,6 +35,9 @@ COPY . . ENV NEXT_TELEMETRY_DISABLED=1 +ARG GIT_COMMIT +ENV GIT_COMMIT=$GIT_COMMIT + RUN \ if [ -f yarn.lock ]; then yarn run build; \ elif [ -f package-lock.json ]; then npm run build; \