Back-end typescript in monorepo: how to get dependencies for docker? Back-end typescript in monorepo: how to get dependencies for docker? docker docker

Back-end typescript in monorepo: how to get dependencies for docker?


You can COPY whatever you'd like in your Dockerfile. If your application is already built on your host, then you can just copy in the build artifacts and its runtime dependencies. For a Node package this might look like

FROM nodeWORKDIR /appCOPY package.json yarn.lock ./RUN yarn install --productionCOPY dist dist/CMD ["node", "/app/dist/index.js"]

Of note, yarn install --production avoids copying in anything in the "devDependencies" section of your package.json file, which would skip things like tsc and webpack.

(This technique is more common for compiled languages – especially Java Dockerfiles tend to just copy in a built .jar or .war file – and in very old Docker that pre-dates multi-stage builds.)