-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
38 lines (30 loc) · 999 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
FROM node:20.17.0-alpine AS base
RUN addgroup -S backend && \
adduser -S backend -G backend
#--------------------------------------------------
FROM base AS base-dev
RUN npm install -g --ignore-scripts pnpm
#--------------------------------------------------
FROM base-dev AS build
WORKDIR /app
COPY package.json pnpm-lock.yaml tsconfig.json tsconfig.build.json ./
RUN pnpm install --frozen-lockfile --ignore-scripts
COPY ./src ./src
RUN pnpm run build --webpack
#--------------------------------------------------
FROM base-dev AS production-dev
ARG NODE_ENV=production
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod --ignore-scripts && \
pnpm cache delete
#--------------------------------------------------
FROM base AS production
ARG NODE_ENV=production
WORKDIR /app
COPY --from=production-dev /app/node_modules ./node_modules
COPY --from=build /app/dist ./
COPY package.json ./
USER backend
ENTRYPOINT ["node", "main.js"]
EXPOSE 3000