chore: dockerfile review mode prod

This commit is contained in:
Julien Froidefond
2025-02-21 09:42:00 +01:00
parent 8c13021bfb
commit 455939602a

View File

@@ -1,5 +1,5 @@
# Use Node.js LTS version
FROM node:20-alpine
# Build stage
FROM node:20-alpine AS builder
# Set working directory
WORKDIR /app
@@ -17,9 +17,30 @@ RUN yarn install --frozen-lockfile
COPY . .
# Build the application
RUN yarn build
# Production stage
FROM node:20-alpine AS runner
WORKDIR /app
# Enable Yarn
RUN corepack enable
# Copy package files and install production dependencies only
COPY package.json yarn.lock* ./
RUN yarn install --production --frozen-lockfile
# Copy built application from builder stage
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
# Set environment variables
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Expose the port the app runs on
EXPOSE 3000
# Start the application in production mode by default
CMD ["yarn", "dev"]
# Start the application in production mode
CMD ["yarn", "start"]