diff --git a/Dockerfile b/Dockerfile index ea8adce..229e7fe 100644 --- a/Dockerfile +++ b/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"] \ No newline at end of file +# Start the application in production mode +CMD ["yarn", "start"] \ No newline at end of file