chore: dockerfile review mode prod
This commit is contained in:
29
Dockerfile
29
Dockerfile
@@ -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"]
|
||||
Reference in New Issue
Block a user