Caching dependency compilation in Docker build

It’s the first COPY command that isn’t cached:

remote: Step 1/27 : FROM elixir:1.9.0-alpine as build        
remote:  ---> 7a6d28e4b511        
remote: Step 2/27 : RUN apk add --update git build-base        
remote:  ---> Using cache        
remote:  ---> 11da61788331        
remote: Step 3/27 : RUN mkdir /app        
remote:  ---> Using cache        
remote:  ---> 2a0fd2bc9f5c        
remote: Step 4/27 : WORKDIR /app        
remote:  ---> Using cache        
remote:  ---> 876adb368066        
remote: Step 5/27 : RUN mix local.hex --force &&   mix local.rebar --force        
remote:  ---> Using cache        
remote:  ---> eb75832955a0        
remote: Step 6/27 : ENV MIX_ENV=prod        
remote:  ---> Using cache        
remote:  ---> 3bc485b4dc82        
remote: Step 7/27 : COPY mix.exs ./        
remote:  ---> 2561f54cdafa
<snip>        

This seems to be an issue with Dokku, and not Elixir, so I’m continuing debugging there: Dockerfile builds only caching up to first COPY · Issue #3631 · dokku/dokku · GitHub