Part II: Artifactory as a Caching Mechanism for Package Managers

Part II: Artifactory as a Caching Mechanism for Package Managers

In our previous blog post we discussed the challenges with relying on external servers for downloading pre-build tools such as Curl, CLI, wget, Maven, Gradle, npm and others. We discussed how they can sometimes cause stability issues, also called “Environmental Issues”, that will break the build.

In this second part of the 2-part series, we’ll expand on the solution of using Artifactory remote repositories, applying it for using Homebrew to download and install Mac and Linux applications is simple, as well as Yum and Docker.

Use Case: Homebrew

Here’s how you can download Brew bottles using Artifactory.

Step by step guide

Step 1: Configure Artifactory repository

Create a remote generic repository in Artifactory:

  • Repository Key: homebrew
  • Url: https://homebrew.bintray.com

Step 2: Set ‘HOMEBREW_ARTIFACT_DOMAIN’ environment variable

For anonymous access:

set HOMEBREW_ARTIFACT_DOMAIN=<artifactory-url>/homebrew

For authenticated access:

set HOMEBREW_ARTIFACT_DOMAIN=<artifactory-user>:<artifactory-password>@<artifactory-url>/homebrew

Each brew install command from now will go through Artifactory’s cache.

> Check out Homebrew Bottles hosted in JFrog Bintray

Use Case: Yum

Here’s how you can use an Artifactory remote RPM repository to download your RPM packages using Yum.

Step by step guide

Step 1: Configure Artifactory repository

Create a remote RPM repository in Artifactory:

  • Repository Key: yum
  • Url: http://mirror.centos.org/centos/<version>/os/<architecture>
    • Example: http://mirror.centos.org/centos/7.6.1810/os/x86_64

Step 2: Create a file

/etc/yum.repos.d/artifactory

File content for anonymous access:

[artifactory]HERE
name=artifactory
baseurl=https://<artifactory-url>/yum
enabled=1
gpgcheck=0

File content for authenticated access:

[artifactory]
name=artifactory
baseurl=https://<artifactory-user:<artifactory-password>@<artifactory-url>/yum
enabled=1
gpgcheck=0

Use Case: Docker

Here’s how you can use an Artifactory remote Docker repository to download your Docker images using Docker CLI.

Step by step guide

Step 1: Configure Artifactory repository

Create a remote Docker repository in Artifactory:

Step 2: Login to Docker Registry

You can retrieve this command from the Artifactory using the Set Me Up button.

docker login <your docker domain>

Step 3: Docker Pull

docker pull <your docker domain>/<docker image>:<docker tag>
As an alternative, you can also manage your Docker images using the free JFrog Container Registry.

 

Try these out for yourself!