-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (42 loc) · 1.54 KB
/
Dockerfile
File metadata and controls
45 lines (42 loc) · 1.54 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
# Stage 1: Install development dependencies
FROM node:24-alpine AS development-dependencies-env
# Copy the entire project, including package.json and pnpm-lock.yaml
COPY . /app
WORKDIR /app
# Install pnpm globally using npm
RUN npm install -g pnpm
# Install dependencies using pnpm (will use pnpm-lock.yaml if present)
RUN pnpm install
# Stage 2: Install production dependencies
FROM node:24-alpine AS production-dependencies-env
# Copy only package.json and pnpm-lock.yaml for dependency installation
COPY ./package.json ./pnpm-lock.yaml /app/
WORKDIR /app
# Install pnpm globally using npm
RUN npm install -g pnpm
# Install production dependencies only using pnpm
RUN pnpm install --prod
# Stage 3: Build the application
FROM node:24-alpine AS build-env
# Copy the entire project
COPY . /app/
# Copy node_modules from development-dependencies-env stage
COPY --from=development-dependencies-env /app/node_modules /app/node_modules
WORKDIR /app
# Install pnpm globally using npm
RUN npm install -g pnpm
# Run the build script using pnpm
RUN pnpm run build
# Stage 4: Final production image
FROM node:24-alpine
# Copy necessary files for running the app
COPY ./package.json ./server.js /app/
# Copy production node_modules from production-dependencies-env stage
COPY --from=production-dependencies-env /app/node_modules /app/node_modules
# Copy build output from build-env stage
COPY --from=build-env /app/build /app/build
WORKDIR /app
# Install pnpm globally using npm for the start command
RUN npm install -g pnpm
# Start the application using pnpm
CMD ["pnpm", "run", "start"]