-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
40 lines (28 loc) · 874 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
# Stage 1: Build the application
FROM node:18 AS builder
# Set the working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies, including development dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Install TypeScript types for ws
RUN npm install --save-dev @types/ws
# Build the Next.js application
RUN npm run build
# Stage 2: Create the final slim image
FROM node:18-slim
# Set the working directory
WORKDIR /app
# Copy only the necessary build artifacts from the previous stage
COPY --from=builder /app/.next /app/.next
COPY --from=builder /app/public /app/public
COPY --from=builder /app/package*.json /app/
# Install only production dependencies
RUN npm install --only=production
# Expose the application port
EXPOSE 3000
# Start the application
CMD ["npm", "start"]