-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
38 lines (26 loc) · 738 Bytes
/
Copy pathdockerfile
File metadata and controls
38 lines (26 loc) · 738 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
# Use official Node.js image as a base
FROM node:18-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package.json package-lock.json ./
# Install dependencies
RUN npm ci
# Copy the rest of the application
COPY . .
# Build the Next.js application
RUN npm run build
# Install only production dependencies
RUN npm ci --omit=dev
# Use a lightweight image for production
FROM node:18-alpine AS runner
# Set working directory
WORKDIR /app
# Copy built files from the builder stage
COPY --from=builder /app ./
# Set environment variable to production
ENV NODE_ENV=production
# Expose the Next.js default port
EXPOSE 3000
# Start the Next.js application
CMD ["npm", "run", "start"]