From 4e74e4b5c985f4950bf497b46bf06f448f00077a Mon Sep 17 00:00:00 2001 From: CTO Date: Fri, 10 Apr 2026 21:06:04 +0000 Subject: [PATCH] fix: pass git commit hash as Docker build arg so footer shows correctly git is not available inside the node:20-alpine Docker image, so git rev-parse in next.config.ts falls back to 'dev'. Now the commit hash is passed as a COMMIT_HASH build arg from the host where git is available, ensuring the footer displays the real commit hash. Co-Authored-By: Paperclip --- .gitea/workflows/deploy.yml | 3 ++- Dockerfile | 2 ++ deploy.sh | 3 ++- docker-compose.yml | 5 ++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 3acd9d8..3c661eb 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -17,6 +17,7 @@ jobs: - name: Build and deploy run: | cd /home/remmer/StageAI + export COMMIT_HASH=$(git rev-parse --short HEAD) docker compose build app docker compose up -d app - echo "Deployed commit: $(git rev-parse --short HEAD)" + echo "Deployed commit: $COMMIT_HASH" diff --git a/Dockerfile b/Dockerfile index 0ebd024..0b17350 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,8 @@ RUN npm ci FROM base AS builder WORKDIR /app +ARG COMMIT_HASH=dev +ENV NEXT_PUBLIC_BUILD_HASH=$COMMIT_HASH COPY --from=deps /app/node_modules ./node_modules COPY . . RUN npm run build diff --git a/deploy.sh b/deploy.sh index db20639..c592f89 100755 --- a/deploy.sh +++ b/deploy.sh @@ -38,8 +38,9 @@ git reset --hard "origin/$BRANCH" echo "Updated to: $(git log --oneline -1)" # Rebuild containers +export COMMIT_HASH=$(git rev-parse --short HEAD) echo "" -echo "Rebuilding containers..." +echo "Rebuilding containers (commit: $COMMIT_HASH)..." docker compose -p "$PROJECT_NAME" build --no-cache app if [[ "$BUILD_ONLY" == true ]]; then diff --git a/docker-compose.yml b/docker-compose.yml index e453948..ac665b2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,9 @@ services: app: - build: . + build: + context: . + args: + COMMIT_HASH: ${COMMIT_HASH:-dev} ports: - "3002:3000" environment: