-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
39 lines (29 loc) · 871 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Stage 1: Build
FROM node:18-alpine AS builder
# Set working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json (or yarn.lock) to install dependencies
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application files
COPY . .
# Build the Next.js app
RUN npm run build
# Stage 2: Production
FROM node:18-alpine AS production
# Set working directory
WORKDIR /app
ENV NODE_ENV production
# Install production dependencies only
COPY package*.json ./
RUN npm install --only=production
# Copy the build from the previous stage
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/next.config.mjs ./
# Expose port 3000
EXPOSE 3000
# Start the application in production mode
CMD ["npm", "run", "start"]