Skip to content

Commit ea18b67

Browse files
HishamHisham
Hisham
authored and
Hisham
committed
Merge branch 'master' of https://github.com/hishamanver/docker-registry-proxy into feature/shared-digest-caching
2 parents 8f88039 + 45ad55d commit ea18b67

File tree

6 files changed

+76
-4
lines changed

6 files changed

+76
-4
lines changed

Diff for: .github/workflows/master-latest.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
uses: docker/login-action@v1
3737
with:
3838
registry: ghcr.io
39-
username: ${{ secrets.DOCKER_GITHUB_USERNAME }}
40-
password: ${{ secrets.DOCKER_GITHUB_PAT }}
39+
username: ${{ github.repository_owner }} # github username or org
40+
password: ${{ secrets.GITHUB_TOKEN }} # github actions builtin token. repo has to have pkg access.
4141

4242
# the arm64 is of course much slower due to qemu, so build and push amd64 **first**
4343
# due to the way manifests work, the gap between this and the complete push below

Diff for: .github/workflows/tags.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ jobs:
4949
uses: docker/login-action@v1
5050
with:
5151
registry: ghcr.io
52-
username: ${{ secrets.DOCKER_GITHUB_USERNAME }}
53-
password: ${{ secrets.DOCKER_GITHUB_PAT }}
52+
username: ${{ github.repository_owner }} # github username or org
53+
password: ${{ secrets.GITHUB_TOKEN }} # github actions builtin token. repo has to have pkg access.
5454

5555
# the arm64 is of course much slower due to qemu, so build and push amd64 **first**
5656
# due to the way manifests work, the gap between this and the complete push below

Diff for: Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ ENV MANIFEST_CACHE_DEFAULT_TIME="1h"
9797
# Should we allow actions different than pull, default to false.
9898
ENV ALLOW_PUSH="false"
9999

100+
# If push is allowed, buffering requests can cause issues on slow upstreams.
101+
# If you have trouble pushing, set this to false first, then fix remainig timouts.
102+
# Default is true to not change default behavior.
103+
ENV PROXY_REQUEST_BUFFERING="true"
104+
100105
# Timeouts
101106
# ngx_http_core_module
102107
ENV SEND_TIMEOUT="60s"

Diff for: README.md

+50
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ for this to work it requires inserting a root CA certificate into system trusted
8787
- `hostname`s listed here should be listed in the REGISTRIES environment as well, so they can be intercepted.
8888
- 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`.
8989
- 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`.
90+
- Env `PROXY_REQUEST_BUFFERING`: If push is allowed, buffering requests can cause issues on slow upstreams.
91+
If you have trouble pushing, set this to `false` first, then fix remainig timeouts.
92+
Default is `true` to not change default behavior.
93+
ENV PROXY_REQUEST_BUFFERING="true"
9094
- 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.:
9195
- SEND_TIMEOUT : see [send_timeout](http://nginx.org/en/docs/http/ngx_http_core_module.html#send_timeout)
9296
- CLIENT_BODY_TIMEOUT : see [client_body_timeout](http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_timeout)
@@ -210,6 +214,52 @@ done
210214
wait $pids # Wait for all configurations to end
211215
```
212216

217+
### K3D Cluster
218+
219+
[K3d](https://k3d.io/) is similar to Kind but is based on k3s. In order to run with its registry you need to setup settings like shown below.
220+
221+
```sh
222+
# docker-registry-proxy
223+
docker run -d --name registry-proxy --restart=always \
224+
-v /tmp/registry-proxy/mirror_cache:/docker_mirror_cache \
225+
-v /tmp/registry-proxy/certs:/ca \
226+
rpardini/docker-registry-proxy:0.6.4
227+
228+
export PROXY_HOST=registry-proxy
229+
export PROXY_PORT=3128
230+
export NOPROXY_LIST="localhost,127.0.0.1,0.0.0.0,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.local,.svc"
231+
232+
cat <<EOF > /etc/k3d-proxy-config.yaml
233+
apiVersion: k3d.io/v1alpha3
234+
kind: Simple
235+
name: mycluster
236+
servers: 1
237+
agents: 0
238+
options:
239+
k3d:
240+
wait: true
241+
timeout: "60s"
242+
kubeconfig:
243+
updateDefaultKubeconfig: true
244+
switchCurrentContext: true
245+
env:
246+
- envVar: HTTP_PROXY=http://$PROXY_HOST:$PROXY_PORT
247+
nodeFilters:
248+
- all
249+
- envVar: HTTPS_PROXY=http://$PROXY_HOST:$PROXY_PORT
250+
nodeFilters:
251+
- all
252+
- envVar: NO_PROXY='$NOPROXY_LIST'
253+
nodeFilters:
254+
- all
255+
volumes:
256+
- volume: $REGISTRY_DIR/docker_mirror_certs/ca.crt:/etc/ssl/certs/registry-proxy-ca.pem
257+
nodeFilters:
258+
- all
259+
EOF
260+
261+
k3d cluster create --config /etc/k3d-proxy-config.yaml
262+
```
213263

214264
## Configuring the Docker clients using Docker Desktop for Mac
215265

Diff for: entrypoint.sh

+14
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,20 @@ echo -e "\nTimeout configs: ---"
258258
cat /etc/nginx/nginx.timeouts.config.conf
259259
echo -e "---\n"
260260

261+
# Request buffering
262+
echo "" > /etc/nginx/proxy.request.buffering.conf
263+
if [[ "a${PROXY_REQUEST_BUFFERING}" == "afalse" ]]; then
264+
cat << EOD > /etc/nginx/proxy.request.buffering.conf
265+
proxy_max_temp_file_size 0;
266+
proxy_request_buffering off;
267+
proxy_http_version 1.1;
268+
EOD
269+
fi
270+
271+
echo -e "\nRequest buffering: ---"
272+
cat /etc/nginx/proxy.request.buffering.conf
273+
echo -e "---\n"
274+
261275
# Upstream SSL verification.
262276
echo "" > /etc/nginx/docker.verify.ssl.conf
263277
if [[ "a${VERIFY_SSL}" == "atrue" ]]; then

Diff for: nginx.conf

+3
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
227227

228228
proxy_read_timeout 900;
229229

230+
# Request buffering
231+
include /etc/nginx/proxy.request.buffering.conf;
232+
230233
# Use cache locking, with a huge timeout, so that multiple Docker clients asking for the same blob at the same time
231234
# will wait for the first to finish instead of doing multiple upstream requests.
232235
proxy_cache_lock on;

0 commit comments

Comments
 (0)