trying to get git commit hash to work

This commit is contained in:
corgifist 2025-07-28 19:18:49 +03:00
parent 2ddd8b9d3b
commit 70aa3992f8
2 changed files with 10 additions and 0 deletions

View File

@ -2,6 +2,13 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
output: "standalone", 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; export default nextConfig;

View File

@ -35,6 +35,9 @@ COPY . .
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
ARG GIT_COMMIT
ENV GIT_COMMIT=$GIT_COMMIT
RUN \ RUN \
if [ -f yarn.lock ]; then yarn run build; \ if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \ elif [ -f package-lock.json ]; then npm run build; \