<p>I have a couple of client applications. For each one I have a build pipeline that gets latest code, compiles it and plots the result to a <code>dist</code> folder (containing only html and js files).</p>

<p>These <code>dist</code> folders are synced, using docker volume, to a web server (<code>nginx</code>) container which actually hosts the client application.</p>

<p>The result is that my client is always "up" and I only need to update the <code>dist</code> folder of any client to deploy it, and never need to mess with the web server container.</p>

<p>However, I want to move my deployment to a different approach, of only building the docker images on pipelines (code change) and using them on demand whenever deploying an environment.</p>

<p>The problem would be how to build the web server container while I don't want to rebuild all clients on any change, nor do I want to store the built output in source control. What would be the best approach?</p>

<p>You could consider a <a href="https://docs.docker.com/develop/develop-images/multistage-build/" rel="nofollow noreferrer">multi-stage build</a> with:</p>

<ul>
<li>the first stage being the build of your web server (which never change, so it is cached)</li>
<li>the second stage being the build of your dist folder, to which image you add the web server of the first stage.</li>
</ul>

<p>The end result is an image with both the web server and the static files to serve (instead of those files being in a volume), with only the static files being rebuilt.</p>
