-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerFile
41 lines (29 loc) · 925 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
40
41
# Use an official Node.js image as the base
FROM node:18-alpine AS builder
# Set the working directory
WORKDIR /app
# Copy the package.json and package-lock.json
COPY package.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the Next.js application
RUN npm run build
# Use a lightweight Node.js image for the production environment
FROM node:18-alpine AS runner
# Set the working directory
WORKDIR /app
# Install production dependencies only
COPY package.json ./
RUN npm install --only=production
# Copy the built application from the builder
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/next.config.ts ./next.config.ts
# Expose the port the app runs on
EXPOSE 3000
# Set the environment variable to indicate production
ENV NODE_ENV=production
# Start the Next.js application
CMD ["npm", "start"]