-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathDockerfile.backend
38 lines (33 loc) · 1016 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
35
36
37
38
FROM node:16 as pruner
RUN apt update && \
apt install git
RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm
RUN pnpm add -g turbo
WORKDIR "/app"
RUN pwd
# Prune the workspace for the backend aapp
COPY .git ./.git
COPY . .
RUN pwd
RUN turbo prune --scope=backend --docker
# Add pruned lockfile and package.json's of the pruned subworkspace
FROM pruner as builder
WORKDIR "/app"
COPY --from=pruner /app/out/json/ .
COPY --from=pruner /app/out/pnpm-lock ./pnpm-lock.yaml
# Install only the deps needed to build the target
RUN pnpm install --frozen-lockfile --prod
COPY --from=pruner /app/.git ./.git
COPY --from=pruner /app/out/full/ .
RUN turbo run build --filter=backend
RUN pwd
RUN ls
# Copy source code of pruned subworkspace and build
FROM node:16-alpine
WORKDIR "/app"
EXPOSE 4000
COPY --from=builder /app/apps/backend/dist/ .
COPY --from=pruner /app/out/json/ .
COPY --from=pruner /app/out/pnpm-lock ./pnpm-lock.yaml
RUN pnpm install --production
CMD node ./apps/backend/dist/index.js