Added NEXT_PUBLIC_HCAPTCHA_SITE_KEY to the Dockerfile to pass the hCaptcha site key as an environment variable during the build process. This ensures the key is appropriately injected into the Next.js build.
35 lines
819 B
Docker
35 lines
819 B
Docker
# Use lightweight Node.js 20 base image
|
|
FROM node:20-alpine@sha256:9bef0ef1e268f60627da9ba7d7605e8831d5b56ad07487d24d1aa386336d1944 as builder
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files separately for better Docker caching
|
|
COPY package.json package-lock.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy entire project
|
|
COPY . .
|
|
|
|
# Set it as an environment variable for the build process
|
|
ENV NEXT_PUBLIC_HCAPTCHA_SITE_KEY=${HCAPTCHA_SITE_KEY}
|
|
|
|
# Build the Next.js app
|
|
RUN npm run build
|
|
|
|
# Use a minimal base image for running the app
|
|
FROM node:20-alpine@sha256:9bef0ef1e268f60627da9ba7d7605e8831d5b56ad07487d24d1aa386336d1944
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy built files from the builder stage
|
|
COPY --from=builder /app ./
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Start Next.js in production mode
|
|
CMD ["npm", "run", "start"]
|