Part II: Artifactory as a Caching Mechanism for Package Managers
Note: This blog post was recently updated on August 18, 2021.
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.
Note: Supported for Artifactory 6.9 and above, and Homebrew 3.2.7 and above.
Step by step guide
Step 1: Configure Artifactory repository
Create a remote Docker repository in Artifactory:
- Repository Key: homebrew
- Url: https://ghcr.io
Step 2: Connect Homebrew to Artifactory
export HOMEBREW_ARTIFACT_DOMAIN=<artifactory-url>/homebrew
For authenticated access:
export HOMEBREW_DOCKER_REGISTRY_TOKEN=<artifactory-access-token>
Each brew install command will now go through Artifactory’s cache.
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: https://mirror.centos.org/centos/<version>/os/<architecture>
- Example: https://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:
- Repository Key: docker
- Url: https://registry-1.docker.io/
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!