-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile
38 lines (27 loc) · 949 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
# Step 1: Use an official Node.js runtime as a base image
FROM node:18-alpine AS base
# Step 2: Set working directory
WORKDIR /app
# Step 3: Copy package.json and package-lock.json
COPY package.json package-lock.json ./
# Step 4: Install dependencies
RUN npm install
# Step 5: Copy the rest of the application
COPY . .
# Step 6: Set environment variables for production
ENV NODE_ENV=production
# Step 7: Build the Next.js application
RUN npm run build
# Step 8: Production stage
FROM node:18-alpine AS production
# Step 9: Set working directory
WORKDIR /app
# Step 10: Copy built application and dependencies from base stage
COPY --from=base /app/package.json /app/package-lock.json ./
COPY --from=base /app/.next ./.next
COPY --from=base /app/public ./public
COPY --from=base /app/node_modules ./node_modules
# Step 11: Expose the port Next.js runs on
EXPOSE 3000
# Step 12: Set the command to start the application
CMD ["npm", "start"]