-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
39 lines (29 loc) · 937 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
# Stage 1: Base image with global tools
FROM node:18-alpine AS base
RUN npm install -g pnpm pm2
# Stage 2: Install dependencies
FROM base AS dependencies
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
COPY scripts/prepare.mjs ./scripts/prepare.mjs
RUN pnpm install --frozen-lockfile
# Stage 3: Build the application
FROM base AS build
WORKDIR /app
COPY . .
COPY --from=dependencies /app/node_modules ./node_modules
RUN pnpm build
# Stage 4: Install production dependencies
FROM base AS production-dependencies
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
COPY scripts/prepare.mjs ./scripts/prepare.mjs
RUN NODE_ENV=production pnpm install --frozen-lockfile --prod
# Stage 5: Deploy
FROM base AS deploy
WORKDIR /app
COPY package.json ./
COPY --from=build /app/dist/ ./dist/
COPY --from=production-dependencies /app/node_modules ./node_modules
COPY ecosystem.config.js ./
CMD ["pm2-runtime", "start", "ecosystem.config.js"]