-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (25 loc) · 874 Bytes
/
Dockerfile
File metadata and controls
36 lines (25 loc) · 874 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
# Stage 1: Build the application
FROM node:21-slim AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install only production dependencies initially (this step is cached)
RUN npm install --only=production
# Install all dependencies, including devDependencies for building
COPY . .
RUN npm install
# Build the Next.js application for production
RUN npm run build
# Stage 2: Run the application
FROM node:21-slim
# Set NODE_ENV to production
ENV NODE_ENV=production
# Set the working directory inside the container
WORKDIR /app
# Copy the built application and dependencies from the builder stage
COPY --from=builder /app /app
# Expose the port that your application will run on
EXPOSE 8080
# Command to run the application
CMD ["npm", "run", "start"]