Skip to content

Commit 3abc2f0

Browse files
mwallace582rpardini
authored andcommitted
Add support for Google rtifact Registry (GAR)
1 parent e3f1eee commit 3abc2f0

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ for this to work it requires inserting a root CA certificate into system trusted
9393
- Env `AUTH_REGISTRIES`: space separated list of `hostname:username:password` authentication info.
9494
- `hostname`s listed here should be listed in the REGISTRIES environment as well, so they can be intercepted.
9595
- Env `AUTH_REGISTRIES_DELIMITER` to change the separator between authentication info. By default, a space: "` `". If you use keys that contain spaces (as with Google Cloud Registry), you should update this variable, e.g. setting it to `AUTH_REGISTRIES_DELIMITER=";;;"`. In that case, `AUTH_REGISTRIES` could contain something like `registry1.com:user1:pass1;;;registry2.com:user2:pass2`.
96-
- Env `AUTH_REGISTRY_DELIMITER` to change the separator between authentication info *parts*. By default, a colon: "`:`". If you use keys that contain single colons, you should update this variable, e.g. setting it to `AUTH_REGISTRIES_DELIMITER=":::"`. In that case, `AUTH_REGISTRIES` could contain something like `registry1.com:::user1:::pass1 registry2.com:::user2:::pass2`.
96+
- Env `AUTH_REGISTRY_DELIMITER` to change the separator between authentication info *parts*. By default, a colon: "`:`". If you use keys that contain single colons, you should update this variable, e.g. setting it to `AUTH_REGISTRY_DELIMITER=":::"`. In that case, `AUTH_REGISTRIES` could contain something like `registry1.com:::user1:::pass1 registry2.com:::user2:::pass2`.
9797
- Env `PROXY_REQUEST_BUFFERING`: If push is allowed, buffering requests can cause issues on slow upstreams. If you have trouble pushing, set this to `false` first, then fix remaining timeouts. Default is `true` to not change default behavior.
9898
- Timeouts ENVS - all of them can pe specified to control different timeouts, and if not set, the defaults will be the ones from `Dockerfile`. The directives will be added into `http` block.:
9999
- SEND_TIMEOUT : see [send_timeout](http://nginx.org/en/docs/http/ngx_http_core_module.html#send_timeout)
@@ -185,6 +185,31 @@ docker run --rm --name docker_registry_proxy -it \
185185
rpardini/docker-registry-proxy:0.6.5
186186
```
187187

188+
### Google Artifact Registry (GAR) auth
189+
190+
For Google Artifact Registry (GAR), username should be `_json_key` and the password should be the contents of the service account JSON.
191+
Check out [GAR docs](https://cloud.google.com/artifact-registry/docs/docker/authentication#json-key).
192+
193+
The service account key is in JSON format, it contains spaces ("` `") and colons ("`:`").
194+
195+
To be able to use GAR you should set `AUTH_REGISTRIES_DELIMITER` to something different than space (e.g. `AUTH_REGISTRIES_DELIMITER=";;;"`) and `AUTH_REGISTRY_DELIMITER` to something different than a single colon (e.g. `AUTH_REGISTRY_DELIMITER=":::"`).
196+
197+
GAR repositories have different domain names depending on the region in which they are hosted. Separate `REGISTRIES` and `AUTH_REGISTRIES` entries must be defined for each region's domain name. `us-east1-docker.pkg.dev` and `us-central1-docker.pkg.dev` are used in the example below.
198+
199+
Example with GAR using credentials from a service account from a key file `servicekey.json`:
200+
201+
```bash
202+
docker run --rm --name docker_registry_proxy -it \
203+
-p 0.0.0.0:3128:3128 -e ENABLE_MANIFEST_CACHE=true \
204+
-v $(pwd)/docker_mirror_cache:/docker_mirror_cache \
205+
-v $(pwd)/docker_mirror_certs:/ca \
206+
-e REGISTRIES="us-east1-docker.pkg.dev us-central1-docker.pkg.dev" \
207+
-e AUTH_REGISTRIES_DELIMITER=";;;" \
208+
-e AUTH_REGISTRY_DELIMITER=":::" \
209+
-e AUTH_REGISTRIES="us-east1-docker.pkg.dev:::_json_key:::$(cat servicekey.json);;;us-central1-docker.pkg.dev:::_json_key:::$(cat servicekey.json);;;auth.docker.io:::dockerhub_username:::dockerhub_password" \
210+
rpardini/docker-registry-proxy:0.6.5
211+
```
212+
188213
### Kind Cluster
189214

190215
[Kind](https://github.com/kubernetes-sigs/kind/) is a tool for running local Kubernetes clusters using Docker container “nodes”.

nginx.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ http {
1818
# Include nginx timeout configs
1919
include /etc/nginx/nginx.timeouts.config.conf;
2020

21+
# Support Google Artifact Registry big headers
22+
proxy_buffer_size 128k;
23+
proxy_buffers 4 256k;
24+
2125
# Use a debug-oriented logging format.
2226
log_format debugging escape=json
2327
'{'
@@ -296,6 +300,10 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
296300
set $original_uri $uri;
297301
set $orig_loc $upstream_http_location;
298302

303+
# Special handling for Google Artifact Registry
304+
if ($upstream_http_location !~* "^https?://") {
305+
set $orig_loc "https://${host}${upstream_http_location}";
306+
}
299307
# during this process, nginx will preserve the headers intended for the original destination.
300308
# in most cases thats okay, but for some (eg: google storage), passing an Authorization
301309
# header can cause problems. Also, that would leak the credentials for the registry

0 commit comments

Comments
 (0)