Artifact Repositories: Hosted, Proxy & Virtual
Compiler caches reuse intermediate results inside one build system. Artifact repositories store the finished products, libraries, packages, binaries and container images, under stable names and versions, so that other teams, later pipelines and deployments download them instead of rebuilding them. They also front public registries (Maven Central, npm, PyPI, ConanCenter, Docker Hub) so that builds keep working when those are slow, down or rate-limited.
The big products are JFrog Artifactory, Sonatype Nexus Repository, Azure Artifacts, GitHub Packages, GitLab Package Registry, AWS CodeArtifact and Google Artifact Registry. They differ in formats and licensing (see the Toolkit), but share one model.
Three kinds of repository
| Kind | Artifactory name | Nexus name | What it holds |
|---|---|---|---|
| Hosted | local | hosted | artifacts your organisation publishes: your libraries, release binaries, internal packages |
| Proxy | remote | proxy | a cache of an upstream registry: the first request downloads from upstream, later requests are served locally |
| Virtual | virtual | group | one URL that searches an ordered list of hosted and proxy repositories |
Clients are configured with the virtual URL only:
# pip.conf
[global]
index-url = https://repo.acme.example/api/pypi/pypi-virtual/simplenpm config set registry https://repo.acme.example/api/npm/npm-virtual/
conan remote add acme https://repo.acme.example/artifactory/api/conan/conan-virtual<!-- ~/.m2/settings.xml: route every Maven request through the group -->
<mirror>
<id>acme</id>
<mirrorOf>*</mirrorOf>
<url>https://repo.acme.example/repository/maven-public/</url>
</mirror>Behind that one URL, the repository manager decides where each package comes from. Swapping an upstream, adding a hosted repo or blocking a package becomes a server change, not a change in every project.
Try the pieces locally
The ecosystem courses run small local registries that behave like a hosted repository, in real sessions:
| Ecosystem | Local registry in the course | Lesson |
|---|---|---|
| C/C++ (Conan) | conan_server on port 9300 |
Remotes: conan_server & Artifactory |
| JavaScript | Verdaccio on port 4873 | Publishing to a Registry |
| Python | pypiserver on port 8080 | Publishing with twine & uv publish |
| Java | a file:// Maven repository |
install & deploy |
| .NET | a folder NuGet feed | .NET Builds |
Verdaccio is itself a small proxy + hosted registry (its "uplinks" are proxies), so the model below applies to it directly.
Resolution order matters
The order of repositories inside a virtual repository is a security decision, not only a performance one. If a public proxy is searched before your hosted repository, anyone who publishes a package with the name of one of your internal packages (and a higher version) on the public registry can get their code into your builds. That's dependency confusion (Supply Chain Security).
This model resolves package requests through two virtual repositories with different orders:
hosted = {"acme-logging": ["1.4.0", "1.5.0"], "acme-crypto": ["2.0.1"]}
public = {"requests": ["2.31.0", "2.34.2"], "acme-logging": ["99.0.0"]} # someone squatted the name!
def vkey(v):
return tuple(int(x) for x in v.split("."))
def resolve(name, members, policy):
found = [(repo, v) for repo, index in members for v in index.get(name, [])]
if not found:
return "not found"
if policy == "first-repo-wins":
repo = found[0][0]
best = max((v for r, v in found if r == repo), key=vkey)
return f"{name} {best} from {repo}"
repo, best = max(found, key=lambda rv: vkey(rv[1])) # "highest version anywhere"
return f"{name} {best} from {repo}"
setups = {
"public first, highest version": ([("public-proxy", public), ("hosted", hosted)], "highest"),
"hosted first, first repo wins": ([("hosted", hosted), ("public-proxy", public)], "first-repo-wins"),
}
for label, (members, policy) in setups.items():
print(label)
for pkg in ["requests", "acme-logging", "acme-crypto"]:
print(" ", resolve(pkg, members, policy))public first, highest version
requests 2.34.2 from public-proxy
acme-logging 99.0.0 from public-proxy
acme-crypto 2.0.1 from hosted
hosted first, first repo wins
requests 2.34.2 from public-proxy
acme-logging 1.5.0 from hosted
acme-crypto 2.0.1 from hosted
In the first setup the squatted acme-logging 99.0.0 wins. Real defences go further than ordering: Artifactory and Nexus can exclude patterns from a proxy (acme-* never comes from upstream), npm has scopes (@acme/… mapped to one registry), and many teams reserve their internal names on the public registry as well.
What else a repository manager gives you
- Metadata and search: which versions exist, who published them, which builds used them (Artifactory's build info, Nexus's component metadata).
- Access control: read for everyone, deploy only for CI service accounts, per repository.
- Promotion between maturity levels (next lessons), retention policies, and immutability for releases.
- Checksums on upload and download, plus signature storage (Checksums & Signatures).
- Vulnerability and licence scanning (JFrog Xray, Sonatype Lifecycle/Firewall) and blocking of known-bad components at the proxy.
- Replication between sites, so a team in another region downloads from a nearby copy.
Test yourself
What does a proxy (remote) repository do?
- Hosts your releases
- Caches packages from an upstream registry, downloading each one on first request
- Merges several repositories under one URL
- Signs artifacts
Why should clients be configured with the virtual (group) URL only?
- It's faster to type
- The server then controls which hosted and proxy repositories are searched, in which order
- Hosted repositories can't be read directly
- Proxies need it
In the model, how did acme-logging 99.0.0 get into the first setup?
- Someone published it to the hosted repo
- The public proxy was searched and the highest version won
- A cache bug
- It was promoted