Use multi-stage docker build to remove unused dependencies in deployed image
Implementation idea could be updating ensureNodeDockerfile
:
Rough idea:
FROM node:$NODE_VERSION-alpine as builder
RUN apk add --no-cache git curl openssl1.1-compat-dev
USER node
# ... build project ...
FROM node:$NODE_VERSION-alpine
# ... copy dist, e.g. ...
COPY --from=builder /app/dist/ ./app/
COPY --from=builder /app/node_modules/ ./app/node_modules/
# ... not sure how to deal with Yarn PnP ¯\_(ツ)_/¯ ...
# ... use envs $DOCKERFILE_ADDITIONS $DOCKER_COPY_WORKSPACE_FILES $DOCKER_COPY_AND_INSTALL_APP $DOCKERFILE_ADDITIONS_END ...
```