The Last Dockerfile You Need for NestJS
<h1>The “dev” Stage</h1>
<p>It’s fairly straightforward. All we need to do is to install npm dependencies and apply some of the <a href="https://docs.docker.com/develop/" rel="noopener ugc nofollow" target="_blank">best practices</a>:</p>
<ul>
<li>We’ll use “<a href="https://hub.docker.com/_/node" rel="noopener ugc nofollow" target="_blank">node:alpine</a>” as the based image to produce minimal image size.</li>
<li>We’ll install <a href="https://github.com/nodejs/docker-node#nodealpine" rel="noopener ugc nofollow" target="_blank">missing shared libraries</a> from node:alpine.</li>
<li>We’ll assign a <a href="https://docs.docker.com/engine/reference/builder/#user" rel="noopener ugc nofollow" target="_blank">non-root user</a> to Docker to limit its privileges</li>
<li>We’ll set the environment to “development”.</li>
<li>We’ll install the dependencies based on <a href="https://classic.yarnpkg.com/lang/en/docs/yarn-lock/" rel="noopener ugc nofollow" target="_blank">yarn lock file</a> to achieve consistent installation across machines.</li>
</ul>
<p><a href="https://levelup.gitconnected.com/the-last-dockerfile-you-need-for-nestjs-76cbfe1edf48"><strong>Click Here</strong></a></p>