diff --git a/Dockerfile b/Dockerfile index 2d7da3b..334cbce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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