cloudflare / serverless-registry

A container registry backed by Workers and R2.
Apache License 2.0
998 stars 36 forks source link

Add Registry HTTP client and fallback to http client to a configured registry if R2 fails #7

Closed gabivlj closed 12 months ago

gabivlj commented 12 months ago

Addresses #4.

This has been tested with 1 R2 as fallback and then a Docker Registry with Google Cloud's Artifact solution.

How to configure:

[env.production.vars]
REGISTRIES_JSON = "[{ \"registry\": \"https://<google-cloud-region>-docker.pkg.dev/<project_name>/<repository>\", \"password_env\": \"GCR_PASSWORD\", \"username\": \"_json_key_base64\" }]"

And do

cat ./registry-service-credentials.json | base64 | wrangler --env production secrets put GCR_PASSWORD

This is an experimental feature. Oauth authentication is still very barebones. We haven't tested yet what happens when the registry returns 302 on the HTTP client, that's still a TODO here.

To make this work, a rewrite had to happen with the R2 registry where we have to move most logic to a different file that implements the "Registry" interface.

Most endpoints are implemented by the R2Registry class (that tries to implement the new Registry interface), except content management ones.

What to expect from this changes:

  1. When R2 fails retrieving content in any way, we will fallback to the configured registries in REGISTRIES_JSON.
  2. If R2 failed retrieving the content with a 404, we will try to synchronise the successful registry with R2. (limited to 5GB layers atm).
gabivlj commented 12 months ago

Image pulling is working for me now. Just two more small issues. Thanks.

Done! auth "none" should be working now. I also added a warning in case this is unintended for some people :+1: