-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend.dockerfile
30 lines (27 loc) · 956 Bytes
/
backend.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
FROM node:18.16.0-alpine AS base
RUN apk add --no-cache libc6-compat
RUN npm i -g @nestjs/cli
RUN npm i -g turbo
RUN npm i -g pnpm
FROM base as prunner
WORKDIR /app
COPY . .
RUN turbo prune --scope=@app/backend --docker
FROM base AS builder
WORKDIR /app
COPY --from=prunner /app/out/json/ .
COPY --from=prunner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=prunner /app/tsconfig.json .
RUN pnpm install --frozen-lockfile --prod
COPY --from=prunner /app/out/full/ .
RUN turbo run build --filter=@app/backend
FROM base AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 runner
USER runner
COPY --from=builder --chown=runner:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=runner:nodejs /app/apps/backend/node_modules ./apps/backend/node_modules
COPY --from=builder --chown=runner:nodejs /app/apps/backend/dist ./apps/backend/dist
EXPOSE 4000
CMD ["node", "apps/backend/dist/main.js"]