-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.backend
34 lines (29 loc) · 900 Bytes
/
Dockerfile.backend
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
# Created Base Image for all stages
FROM node:20-alpine3.20 As base
RUN apk add --no-cache libc6-compat && \
npm install -g pnpm
FROM base AS builder
WORKDIR /opt
COPY apps/backend ./apps/backend
COPY pnpm-workspace.yaml ./
COPY packages ./packages
RUN cd apps/backend && \
pnpm install && \
pnpx prisma generate && \
pnpm run build
FROM base AS onlydeps
WORKDIR /opt
COPY apps/backend ./apps/backend
COPY pnpm-workspace.yaml ./
COPY packages ./packages
RUN cd apps/backend && \
pnpm install --production
FROM base As prod
WORKDIR /prod
COPY --from=builder /opt/apps/backend/dist ./apps/backend/dist
COPY --from=builder /opt/apps/backend/prisma ./apps/backend/prisma
COPY --from=builder /opt/apps/backend/node_modules ./apps/backend/node_modules
COPY --from=builder /opt/node_modules ./node_modules
WORKDIR /prod/apps/backend
EXPOSE 3333
CMD [ "node", "dist/main.js" ]