<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="173732" data-post-id="173732">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="qhwa" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/qhwa/120/17564_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  qhwa
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi <a class="mention" href="/u/otijhuis" rel="nofollow">@otijhuis</a>, I  took your idea and made some updates to my dockerfile. Now it works pretty well.</p>
<p>A fresh build takes about 2 minutes, because I have some expensive dependencies. A repeated build with a single line of code changed takes around 5 seconds, which is the same as yours as I follow the same strategy with you.</p>
<p>I split it into smaller stages because I want to make it easy to fit into another project without any assets. Eventually I will update my library <a href="https://hex.pm/packages/dockerize" rel="nofollow">dockerize</a> later.</p>
<p>Currently, the building workflow goes like this:</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/e/0/e0487ca724d9ccce30d9ba45a841e4b02f492560.jpeg" data-download-href="https://forum.elixirforum.com/uploads/default/e0487ca724d9ccce30d9ba45a841e4b02f492560" title="docker-stages" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/optimized/3X/e/0/e0487ca724d9ccce30d9ba45a841e4b02f492560_2_690x358.jpeg" alt="docker-stages" data-base62-sha1="w06fRGCwVfFKTce4CjUBdpnlg76" width="690" height="358" srcset="https://forum.elixirforum.com/uploads/default/optimized/3X/e/0/e0487ca724d9ccce30d9ba45a841e4b02f492560_2_690x358.jpeg, https://forum.elixirforum.com/uploads/default/optimized/3X/e/0/e0487ca724d9ccce30d9ba45a841e4b02f492560_2_1035x537.jpeg 1.5x, https://forum.elixirforum.com/uploads/default/optimized/3X/e/0/e0487ca724d9ccce30d9ba45a841e4b02f492560_2_1380x716.jpeg 2x" data-dominant-color="F7EBEC"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">docker-stages</span><span class="informations">2608×1356 164 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p>
<p>This picture shows what stage will be rebuilt based on the location of the change (green texts on the top left).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="173732" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/could-use-some-feedback-on-this-multistage-dockerfile-1st-elixir-phoenix-deployment/30862/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-173732" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="173732"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #21"></div>
  </section>
</div>
    <div class="postbit" id="173770" data-post-id="173770">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="otijhuis" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/otijhuis/120/12102_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  otijhuis
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Looks good!</p>
<p>You might be able to use the same multistage dockerfile for both elixir and phoenix projects by using the <code>--target</code> option of <code>docker build</code>. One final image stage for phoenix, one for elixir only. When using buildkit it won’t execute what it won’t need and you could pick between <code>docker build --target elixir .</code> and <code>docker build --target phoenix .</code>. You might have to tweak a bit but I suspect it’s possible. I could be wrong though <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="173770" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/could-use-some-feedback-on-this-multistage-dockerfile-1st-elixir-phoenix-deployment/30862/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-173770" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="173770"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #22"></div>
  </section>
</div>
    <div class="postbit" id="173867" data-post-id="173867">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="qhwa" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/qhwa/120/17564_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  qhwa
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yes, I believe it’s possible and that would be interesting. But I’ll keep it as it is now because it will be used in a hex package. In my case of a library generating dockerfiles for other projects, I prefer to keep  them as two templates sharing common small stages. This is only from the perspective from a library though.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="173867" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/could-use-some-feedback-on-this-multistage-dockerfile-1st-elixir-phoenix-deployment/30862/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-173867" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="173867"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>