How to setup a Remote homebrew repository

Batel Tova
2023-02-26 21:24

1. Create a docker remote repository, named homebrew with the following URL:https://ghcr.io as the following example:

User-added image

2. Add the environment variable HOMEBREW_ARTIFACT_DOMAIN, as follows:

export HOMEBREW_ARTIFACT_DOMAIN=<artifactory-url>/artifactory/homebrew

For authenticated access:
export HOMEBREW_DOCKER_REGISTRY_TOKEN=<artifactory-access-token>

Note: Don't use a Subdomain / Ports style Docker URL with Homebrew. The normal Artifactory URL with /homebrew on the end should work with the Brew client, for example "https://artifactory.com/artifactory/homebrew".

3. Now each brew install command will go through Artifactory like the following example:

$brew install wget

$brew install wget

Note: If you get a 401 error, it most likely is the result of the token being invalid or your user not having access. Try allowing Anonymous Access if you see a 401 error.

Homebrew Cask Support
Artifactory supports mirroring Bottles and Formulas by proxying the GitHub Container Registry (https://ghcr.io). Casks are provided by the package author and will be located at arbitrary URL locations which Artifactory won't be able to proxy. Instead you should use standard Forward Proxy environment variables to download these files. 

Please note that there is a bug fix around Cask behavior in Homebrew 3.4.12, earlier versions of the client use the HOMEBREW_BOTTLE_DOMAIN URL to download casks rather than a separate Forward Proxy.