-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (27 loc) · 868 Bytes
/
Dockerfile
File metadata and controls
38 lines (27 loc) · 868 Bytes
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
# Stage 1: Build Stage
FROM node:18-alpine AS build
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code to the container
COPY . .
# Build the Next.js app
RUN npm run build
# Stage 2: Runtime Stage
FROM node:18-alpine
# Set the working directory inside the container
WORKDIR /app
# Copy only necessary files from the build stage
ENV NODE_ENV production
COPY --from=build /app/next.config.js ./next.config.js
COPY --from=build /app/public ./public
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static
# Expose the desired port
EXPOSE 3000
# Start the Next.js app
CMD ["node", "server.js"]