Gitlab docker executor - cache image after before_script : <p>In <code>gitlab-ci</code> there's an option in the <a href="http://doc.gitlab.com/ce/ci/yaml/README.html" rel="noreferrer"><code>.gitlab-ci.yml</code></a> file to execute commands before any of the actual script runs, called <code>before_script</code>. <code>.gitlab-ci.yml</code> examples illustrate installing ancillary programs here. However, what I've noticed is that these changes are not cached in Docker when using a docker executor. I had naively assumed that after running these commands, docker would cache the image, so for the next run or test, docker would just load the cached image produced after <code>before_script</code>. This would drastically speed up builds.</p>

<p>As an example, my <code>.gitlab-ci.yml</code> looks a little like:</p>

<pre><code>image: ubuntu

before_script:
    - apt-get update -qq &amp;&amp; apt-get install -yqq make ...

build:
    script:
        - cd project &amp;&amp; make
</code></pre>

<p>A possible solution is to go to the runner machine and create a docker image that can build my software without any other installation and then reference it in the <code>image</code> section of the yaml file. The downside of this is that whenever I want to add a dependency, I need to log in to the runner machine and update the image before builds will succeed. It would be much nicer if I just had to add the dependency to to the end of <code>apt-get install</code> and have docker / gitlab-ci handle the appropriate caching.</p>

<p>There is also a <code>cache</code> command in <code>.gitlab-ci.yml</code>, which I tried setting to <code>untracked: true</code>, which I thought would cache everything that wasn't a byproduct of my project, but it didn't seem to have any effect.</p>

<p>Is there any way to get the behavior I desire?</p>
