Use GIT_COMMIT_SHA env var instead of execSync for Docker compatibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jakeandClaude Opus 4.6 committed 2026-03-03 12:56:11 -05:00
1 parent ecc6a942a9
commit 1a5a1e631c
5 files changed
+7 -14

No files matched your search

+2
View File
@@ -61,5 +61,7 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_COMMIT_SHA=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
+2
View File
@@ -12,7 +12,9 @@ FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ARG GIT_COMMIT_SHA
ENV NODE_ENV=production
ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
RUN pnpm build
# --- Runner ---
+1 -1
View File
@@ -75,7 +75,7 @@ export default async function SettingsPage() {
Sofa
</a>{" "}
v{APP_VERSION}
{GIT_COMMIT !== "unknown" && (
{GIT_COMMIT && (
<>
{" "}
(
+2 -2
View File
@@ -1,4 +1,4 @@
import packageJson from "../package.json";
import packageJson from "../package.json" with { type: "json" };
export const APP_VERSION = packageJson.version;
export const GIT_COMMIT = process.env.GIT_COMMIT_SHA ?? "unknown";
export const GIT_COMMIT = process.env.GIT_COMMIT_SHA?.slice(0, 7) || "";
-11
View File
@@ -1,16 +1,5 @@
import { execSync } from "node:child_process";
import type { NextConfig } from "next";
process.env.GIT_COMMIT_SHA = (() => {
try {
return execSync("git rev-parse --short HEAD", {
encoding: "utf-8",
}).trim();
} catch {
return "unknown";
}
})();
const imageBaseUrl = process.env.TMDB_IMAGE_BASE_URL || "";
const imageHost = imageBaseUrl
? new URL(imageBaseUrl).hostname