feat: add git commit hash to Docker build process
This commit is contained in:
+6
-3
@@ -4,7 +4,7 @@
|
|||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN apk add --no-cache python3 make g++
|
RUN apk add --no-cache python3 make g++ git
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -18,12 +18,15 @@ RUN npm ci
|
|||||||
# Copy source code
|
# Copy source code
|
||||||
COPY . .
|
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)
|
# 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
|
# 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
|
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" npx prisma generate
|
||||||
|
|
||||||
# Build the application (with dummy DATABASE_URL for static page generation)
|
# Build the application (with dummy DATABASE_URL for static page generation and git commit)
|
||||||
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" npm run build
|
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" NEXT_PUBLIC_GIT_COMMIT=$(git rev-parse --short HEAD) npm run build
|
||||||
|
|
||||||
# Stage 2: Runner
|
# Stage 2: Runner
|
||||||
FROM node:20-alpine AS runner
|
FROM node:20-alpine AS runner
|
||||||
|
|||||||
Reference in New Issue
Block a user