-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (44 loc) · 1.2 KB
/
Dockerfile
File metadata and controls
58 lines (44 loc) · 1.2 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Step 1: Build stage
FROM node:23-alpine AS builder
# Install dependencies required for building native modules
RUN apk add --no-cache \
python3 \
make \
g++ \
pkgconfig \
pixman-dev \
cairo-dev \
pango-dev \
glib-dev \
jpeg-dev \
giflib-dev
# Install pnpm globally
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app
# Copy package.json and pnpm-lock.yaml
COPY package.json pnpm-lock.yaml ./
# Install dependencies using pnpm
RUN pnpm install --frozen-lockfile
# Copy the rest of the application code
COPY . .
# Build the application
RUN pnpm run build
# Step 2: Production stage
FROM node:23-alpine
# Install pnpm globally
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app
# Set NODE_ENV to production
ENV NODE_ENV=production
# Copy only the built application and necessary files from the builder stage
COPY --from=builder /app/package.json ./
COPY --from=builder /app/pnpm-lock.yaml ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
# Expose the port the application runs on
EXPOSE 3000
# Define the command to start the application
CMD ["pnpm", "start"]