forked from taneba/fullstack-graphql-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.backend
37 lines (32 loc) · 916 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
FROM node:16 as pruner
RUN apt update && \
apt install git
RUN yarn global add 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/yarn.lock ./yarn.lock
# Install only the deps needed to build the target
RUN yarn install
COPY --from=pruner /app/.git ./.git
COPY --from=pruner /app/out/full/ .
RUN turbo run build --scope=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/yarn.lock ./yarn.lock
RUN yarn install --production
CMD node ./apps/backend/dist/index.js