Hi, I am trying to dockerize a nodejs application managed in turborepo. Following the docs, I have arrived at the following Dockerfile
FROM node:alpine AS builder
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune express1 --docker
# Installer
FROM node:alpine AS installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app
RUN corepack enable
RUN yarn set version berry
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN yarn install --frozen-lockfile
COPY --from=builder /app/out/full/ .
RUN yarn turbo build --filter=express1
I have left out the final runner part. The app is just a very simple express app with one endpoint that reply “hello world”. The size of the image is an enormous 500MB. Inspecting the node_modules
in the container, I can see all the dev dependencies are installed as well, like turbo, typescript, etc. What I want is, only install the required packages that the application and it’s local packages/library needs. How can I do that?