7

I am trying to build a project using gradle, jdk 8 and deploy it using ansible.

I can't find an up to date docker image that contains all these so I am installing ansible on the fly.

Bitbucket pipelines allegedly has the ability to create custom caches but it doesn't seem to cache the apt dir

image: java:8

pipelines:
  default:
    - step:
        caches:
          - gradle
          - apt
        script:
          - echo 'deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main' >> /etc/apt/sources.list
          - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
          - apt-get update && apt-get install -y ansible
          - bash ./gradlew clean bootJar
definitions:
  caches:
    apt: /var/cache/apt/archives

Results in

Dependency caches
gradle: ~/.gradle/caches        158.37 MB   06 Apr 2018 
apt:    /var/cache/apt/archives 151 Bytes   06 Apr 2018 

EDIT: I added a step to list the directory and not only was there nothing there, i couldn't find any deb files on the whole system

find /var/cache/
<1s
+ find /var/cache/
/var/cache/
/var/cache/apt
/var/cache/apt/archives
/var/cache/apt/archives/partial
/var/cache/apt/archives/lock
/var/cache/ldconfig
/var/cache/ldconfig/aux-cache
/var/cache/debconf
/var/cache/debconf/templates.dat
/var/cache/debconf/config.dat-old
/var/cache/debconf/config.dat
/var/cache/debconf/templates.dat-old
/var/cache/debconf/passwords.dat
/var/cache/fontconfig
/var/cache/fontconfig/d589a48862398ed80a3d6066f4f56f4c-le64.cache-4
/var/cache/fontconfig/7ef2298fde41cc6eeb7af42e48b7d293-le64.cache-4
/var/cache/fontconfig/3830d5c3ddfd5cd38a049b759396e72e-le64.cache-4
/var/cache/fontconfig/CACHEDIR.TAG
/var/cache/fontconfig/4c599c202bc5c08e2d34565a40eac3b2-le64.cache-4
find / -name "*.deb"
<1s
+ find / -name "*.deb"
opticyclic
  • 7,412
  • 12
  • 81
  • 155
  • Guess I am late to the party but this is sort of duplicate for https://stackoverflow.com/q/45962068/11715259 . Just linking it because the other one received more attention and answers, I don't think closing this question would be any worth and the one answer here points in the right direction. – N1ngu Jan 16 '23 at 14:38

1 Answers1

5

In Ubuntu-based docker images there is usually an apt hook that deletes the packages after installation. It is located in /etc/apt/apt.conf.d/.

In ubuntu:19.04, the file containing the hook is called docker-clean. If you remove that, you will be able to find all the packages that were downloaded in /var/cache/apt/archives.

As a consequence, just adding the following at the beginning of your pipeline should allow your apt cache to work as expected:

rm /etc/apt/apt.conf.d/docker-clean
Elia Geretto
  • 387
  • 4
  • 10
  • Also: avoid `apt`, use `apt-get`, and cache `/var/lib/apt/lists` as well. Otherwise this answer would be incomplete. See https://stackoverflow.com/a/72959639/11715259 – N1ngu Jan 16 '23 at 14:41