feat: add git commit hash to Docker build process

This commit is contained in:
2026-03-31 11:44:46 -07:00
parent 0ae4a171fd
commit d00dc0f096
+6 -3
View File
@@ -4,7 +4,7 @@
FROM node:20-alpine AS builder
# Install dependencies
RUN apk add --no-cache python3 make g++
RUN apk add --no-cache python3 make g++ git
# Set working directory
WORKDIR /app
@@ -18,12 +18,15 @@ RUN npm ci
# Copy source code
COPY . .
# Get git commit hash
RUN GIT_COMMIT_HASH=$(git rev-parse --short HEAD) && echo "GIT_COMMIT_HASH=$GIT_COMMIT_HASH" > .env
# Generate Prisma client (with dummy PostgreSQL DATABASE_URL for build-time generation)
# Note: A dummy URL is used since the real database is not available during build
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" npx prisma generate
# Build the application (with dummy DATABASE_URL for static page generation)
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" npm run build
# Build the application (with dummy DATABASE_URL for static page generation and git commit)
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" NEXT_PUBLIC_GIT_COMMIT=$(git rev-parse --short HEAD) npm run build
# Stage 2: Runner
FROM node:20-alpine AS runner