How to cache apt installs?

In my pipeline, I have below apt packages to be installed.


  before_script:
    - apt-get -yq update
    - apt-get -yq install software-properties-common
    - apt-get -yq install python3-pip python-is-python3 rsync rpm
    - apt-get -yq install ruby ruby-dev rubygems build-essential
    - gem install fpm

How to add a cache to this job to speed up all these installs?

Hi @uday.reddy3

Most people in this situation would probably build their own Docker image, store it in the GitLab container registry, and then use that in their pipeline. This blog post describes how to do that.

If you really want to use caching, that’s only complicated because apt-get puts all its files in odd places. This comment and the rest of that issue should give you some ideas on how to get started.