-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (29 loc) · 990 Bytes
/
Dockerfile
File metadata and controls
43 lines (29 loc) · 990 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
39
40
41
42
43
# Stage 1: Build
FROM node:20-alpine 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 package-lock.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code to the working directory
COPY . .
ARG NEXT_PUBLIC_NODE_WS=""
RUN printf "$NEXT_PUBLIC_NODE_WS" >> .env.production
# Build the application
RUN npm run build
# Stage 2: Production
FROM node:20-alpine
# Set the working directory inside the container
WORKDIR /app
# Copy only the necessary files from the build stage
COPY --from=builder /app/package.json /app/package-lock.json ./
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/node_modules ./node_modules
# Install only production dependencies
RUN npm install --only=production
# Expose the port the app runs on
EXPOSE 3000
# Start the application
CMD ["npm", "run", "start"]