Beginning with version 3.17, Sonatype Nexus Repository Manager supports APT (Advanced Package Tool) repositories. APT is a set of tools used to search, install, and manage packages on Debian, Ubuntu, and similar Linux distributions. With this new release, you can now host your own local APT repos. Developers benefit from no longer having to rely on connecting externally to a public repository every time an often-used package is needed.
In the case of Debian-based Docker containers, the ability to locally cache Debian packages from public repositories can save copious amounts of time when rebuilding your containers. This can do wonders especially for containers built frequently in a CI pipeline and for the more traditional use-case of provisioning virtual machines.
In this simple bare-bones Dockerfile, we download the latest Ubuntu image and run it:
RUN apt-get update && apt-get -y dist-upgrade
The Ubuntu image is pulling the APT packages from the repository listed in our sources.list file which, in this case, points to the public Ubuntu repository. (For more benefits of caching your necessary build components, you can use Repository Manager as a local Docker registry.)
It’s a waste of time to go out to the internet to download a large OS package. Imagine the time being spent on Docker jobs where each build relies on reaching out externally to download a large OS image.
Why worry about the nature of network issues -- latency, bandwidth, connectivity, etc. -- when you can avoid all of that and store these OS packages locally in Sonatype Nexus Repository Manager? If a developer or build has already downloaded the needed package from the public repository, all can subsequently rely on the package cache within their organization’s network.
As our research shows, companies are adopting better DevOps practices and techniques - such as using repositories and packaging applications in containers - to reap the benefits of faster building and provisioning. With 3.17, this is now possible. All you need to do is create a proxy APT repository in NXRM which points to the public repository (e.g. http://archive.ubuntu.com/ubuntu/)
Then have your /etc/apt/sources.list file point to your NXRM repo.
deb http://admin:admin123@localhost:8081/repository/apt-proxy-updates/ bionic-updates main
Your new Dockerfile should look something like this:
$ apt-get update && apt-get -y dist-upgrade
Get:1 http://localhost:8081/repository/apt-proxy-updates bionic-updates InRelease [88.7 kB]
Get:2 http://localhost:8081/repository/apt-proxy bionic InRelease [242 kB]
Get:3 http://localhost:8081/repository/apt-proxy-updates bionic-updates/main amd64 Packages [881 kB]
Get:4 http://localhost:8081/repository/apt-proxy bionic/main amd64 Packages [1344 kB]
Fetched 2556 kB in 3s (928 kB/s)
More detailed instructions on how to create your APT repos can be found in our technical documentation.