<p>I have an python application whose docker build takes about 15-20 minutes.
Here is how my Dockerfile looks like more or less</p>

<pre><code>FROM ubuntu:18.04
...
COPY . /usr/local/app
RUN pip install -r /usr/local/app/requirements.txt
...
CMD ...
</code></pre>

<p>Now if I use skaffold, any code change triggers a rebuild and it is going to do a reinstall of all requirements(as from the COPY step everything else is going to be rebuild) regardless of whether they were already installed. iIn docker-compose this issue would be solved using volumes. In kubernetes, if we use volumes in the following way:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
name: test
spec:
containers:
- image: test:test
name: test-container
volumeMounts:
- mountPath: /usr/local/venv # this is the directory of the 
# virtualenv of python
    name: test-volume
volumes:
- name: test-volume
  awsElasticBlockStore:
    volumeID: &lt;volume-id&gt;
    fsType: ext4
</code></pre>

<p>will this extra requirements build be resolved with skaffold?</p>

Rajdeep Mukherjee
<p>I can't speak for skaffold specifically but the container image build can be improved. If there is layer caching available then only reinstall the dependencies when your <code>requirements.txt</code> changes. This is documented in the "ADD or COPY" <a href="https://docs.docker.com/develop/develop-images/dockerfile_best-practices/" rel="nofollow noreferrer">Best Practices</a>.</p>

<pre><code>FROM ubuntu:18.04
...
COPY requirements.txt /usr/local/app/
RUN pip install -r /usr/local/app/requirements.txt
COPY . /usr/local/app
...
CMD ...
</code></pre>

<p>You may need to trigger updates some times if the module versions are loosely defined and say you want a new patch version. I've found requirements should be specific so versions don't slide underneath your application without your knowledge/testing.</p>

<h1>Kaniko in-cluster builds</h1>

<p>For kaniko builds to make use of a cache in a cluster where there is no persistent storage by default, kaniko needs either a persistent volume mounted (<code>--cache-dir</code>) or a container image repo (<code>--cache-repo</code>) with the layers available.</p>
