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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>the Docker <code>COPY</code> command should perform a checksum of the given source files, and use that for caching. It should not even check the creation/modification time of the files.</p>
<p>The <code>RUN</code> command should only use the command string to determine whether to use the cache or re-run the command.</p>
<p>Therefore, the dependencies will be re-fetched if any of the following conditions apply:</p>
<ul>
<li>
<p>The Dockerfile line <code>RUN mix deps.get</code> or any Dockerfile command appearing before it was modified</p>
</li>
<li>
<p>The content of <code>mix.exs</code> or <code>mix.lock</code> changed</p>
</li>
</ul>
<p>As I understand, you say that none of those happened, and the dependencies are still re-fetched. In order to understand what is going on, it would be interesting to check:</p>
<ul>
<li>
<p>What is the first Dockerfile command to invalidate the cache? Is it <code>RUN mix deps.get</code> or something even earlier?</p>
</li>
<li>
<p>If you separate the <code>COPY mix.exs mix.lock ./</code> into two different <code>COPY</code> commands, which one uses the cache and which does not?</p>
</li>
</ul>
<p>I hope we can guess what’s wrong with this information <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="138497" 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/caching-dependency-compilation-in-docker-build/24273/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-138497" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="138497"
                     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 #12"></div>
  </section>
</div>
    <div class="postbit" id="138498" data-post-id="138498">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Another possibility could be that the environment where you are building the docker image does not support caching (e.g. on CI it is usually necessary to configure caching of artifacts, otherwise every build starts from a fresh context and won’t find any cached layer to reuse)</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="138498" 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/caching-dependency-compilation-in-docker-build/24273/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-138498" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="138498"
                     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 #13"></div>
  </section>
</div>
    <div class="postbit" id="138585" data-post-id="138585">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/tao" rel="nofollow">@tao</a> did you manage to find out what the problem was? I am curious <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="138585" 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/caching-dependency-compilation-in-docker-build/24273/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-138585" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="138585"
                     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 #14"></div>
  </section>
</div>
    <div class="postbit" id="138594" data-post-id="138594">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tao" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tao/120/22926_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tao
                      <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>The first command to <em>not</em> use the cache is the first <code>COPY</code>:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">remote: Sending build context to Docker daemon  162.3kB        
remote: 
remote: 
remote: Step 1/26 : FROM elixir:1.9.0-alpine as build        
remote:  ---&gt; 7a6d28e4b511        
remote: Step 2/26 : RUN apk add --update git build-base        
remote:  ---&gt; Using cache        
remote:  ---&gt; 11da61788331        
remote: Step 3/26 : RUN mkdir /app        
remote:  ---&gt; Using cache        
remote:  ---&gt; 2a0fd2bc9f5c        
remote: Step 4/26 : WORKDIR /app        
remote:  ---&gt; Using cache        
remote:  ---&gt; 876adb368066        
remote: Step 5/26 : RUN mix local.hex --force &amp;&amp;   mix local.rebar --force        
remote:  ---&gt; Using cache        
remote:  ---&gt; eb75832955a0        
remote: Step 6/26 : ENV MIX_ENV=prod        
remote:  ---&gt; Using cache        
remote:  ---&gt; 3bc485b4dc82        
remote: Step 7/26 : COPY mix.exs mix.lock ./        
remote:  ---&gt; 223512ca1219        
remote: Step 8/26 : COPY config config        
remote:  ---&gt; 09c813490fe9        
&lt;snip&gt;
</code></pre>
<p>I’m just separating it into two commands like you suggested now. I’ll update here when I try this out! FWIW this is running on Dokku, so caching should be supported.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="138594" data-batch-url="/posts/batch_likers">
                        1
                      </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/caching-dependency-compilation-in-docker-build/24273/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-138594" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="138594"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-most-liked cat-most-liked" title="One of the top 2 liked posts in this thread!"></div>
  </section>
</div>
    <div class="postbit" id="138598" data-post-id="138598">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tao" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tao/120/22926_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tao
                      <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>It’s the first <code>COPY</code> command that isn’t cached:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">remote: Step 1/27 : FROM elixir:1.9.0-alpine as build        
remote:  ---&gt; 7a6d28e4b511        
remote: Step 2/27 : RUN apk add --update git build-base        
remote:  ---&gt; Using cache        
remote:  ---&gt; 11da61788331        
remote: Step 3/27 : RUN mkdir /app        
remote:  ---&gt; Using cache        
remote:  ---&gt; 2a0fd2bc9f5c        
remote: Step 4/27 : WORKDIR /app        
remote:  ---&gt; Using cache        
remote:  ---&gt; 876adb368066        
remote: Step 5/27 : RUN mix local.hex --force &amp;&amp;   mix local.rebar --force        
remote:  ---&gt; Using cache        
remote:  ---&gt; eb75832955a0        
remote: Step 6/27 : ENV MIX_ENV=prod        
remote:  ---&gt; Using cache        
remote:  ---&gt; 3bc485b4dc82        
remote: Step 7/27 : COPY mix.exs ./        
remote:  ---&gt; 2561f54cdafa
&lt;snip&gt;        
</code></pre>
<p>This seems to be an issue with Dokku, and not Elixir, so I’m continuing debugging there: <a href="https://github.com/dokku/dokku/issues/3631" class="inline-onebox" rel="noopener nofollow ugc">Dockerfile builds only caching up to first COPY · Issue #3631 · dokku/dokku · GitHub</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="138598" 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/caching-dependency-compilation-in-docker-build/24273/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-138598" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="138598"
                     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 #16"></div>
  </section>
</div>
    <div class="postbit" id="138613" data-post-id="138613">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Does it cache using <code>docker</code> instead? Just basic bare docker?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="138613" 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/caching-dependency-compilation-in-docker-build/24273/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-138613" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="138613"
                     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 #17"></div>
  </section>
</div>
    <div class="postbit" id="138755" data-post-id="138755">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tao" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tao/120/22926_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tao
                      <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>I think so, but not sure. Looks like they’ve had some issues with multi-stage builds (like this one) in the past.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="138755" 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/caching-dependency-compilation-in-docker-build/24273/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-138755" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="138755"
                     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 #18"></div>
  </section>
</div>
    <div class="postbit" id="138756" data-post-id="138756">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The provided dockerfile is not multistage. Have you tried using <code>docker</code> or are you just guessing?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="138756" 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/caching-dependency-compilation-in-docker-build/24273/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-138756" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="138756"
                     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 #19"></div>
  </section>
</div>
    <div class="postbit" id="138763" data-post-id="138763">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tao" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tao/120/22926_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tao
                      <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>Ah yeah, I just copied the build stage – I’m using the same one as in the <a href="https://hexdocs.pm/phoenix/releases.html#containers" rel="noopener nofollow ugc">Phoenix docs</a>, which is multistage.</p>
<p>Just tried with <code>docker</code> on my local machine. Caching works as expected there, so this must be a Dokku problem!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="138763" 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/caching-dependency-compilation-in-docker-build/24273/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-138763" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="138763"
                     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 #20"></div>
  </section>
</div>
    <div class="postbit" id="330053" data-post-id="330053">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Whoever is coming now.<br>
I have an umbrella app. Just mix.exs and mix.lock file copying won’t allow me to get all deps. So what I do is copy mix.exs from all the sub apps and make same structure like umbrella app but for configs of these sub apps I copy umrellas config. Then do</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">run mix deps.get --all
mix deps.compile
</code></pre>
<p>after this</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">copy apps /build/apps

digest build etc
</code></pre>
<p>from this stage onwards it’s always new. Again to be specific my docker file multistaged, so in second stage I install bare minimums are copy stuff from first stage</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="330053" 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/caching-dependency-compilation-in-docker-build/24273/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-330053" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="330053"
                     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>