Skip to content

Commit ad75dce

Browse files
author
ricardop
committed
Merge branch 'pull/22'
2 parents 8e43333 + f3d2eef commit ad75dce

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ for this to work it requires inserting a root CA certificate into system trusted
2020
- Expose port 3128 to the network
2121
- Map volume `/docker_mirror_cache` for up to 32gb of cached images from all registries
2222
- Map volume `/ca`, the proxy will store the CA certificate here across restarts
23+
- Env `CACHE_MAX_SIZE` (default `32g`): set the max size to be used for caching local Docker image layers. Use [Nginx sizes](http://nginx.org/en/docs/syntax.html).
2324
- Env `REGISTRIES`: space separated list of registries to cache; no need to include Docker Hub, its already there.
2425
- Env `AUTH_REGISTRIES`: space separated list of `hostname:username:password` authentication info.
2526
- `hostname`s listed here should be listed in the REGISTRIES environment as well, so they can be intercepted.
@@ -126,7 +127,6 @@ Yeah. Docker Inc should do it. So should NPM, Inc. Wonder why they don't. 😼
126127

127128
- Allow using multiple credentials for DockerHub; this is possible since the `/token` request includes the wanted repo as a query string parameter.
128129
- Test and make auth work with quay.io, unfortunately I don't have access to it (_hint, hint, quay_)
129-
- Make the cache size configurable, today it's fixed at 32gb.
130130
- Hide the mitmproxy building code under a Docker build ARG.
131131
- I hope that in the future this can also be used as a "Developer Office" proxy, where many developers on a fast local network
132132
share a proxy for bandwidth and speed savings; work is ongoing in this direction.

entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ fi
8181
echo " listen 443 ssl default_server;" > /etc/nginx/caching.layer.listen
8282
echo "error_log /var/log/nginx/error.log warn;" > /etc/nginx/error.log.debug.warn
8383

84+
# Set Docker Registry cache size, by default, 32 GB ('32g')
85+
CACHE_MAX_SIZE=${CACHE_MAX_SIZE:-32g}
86+
87+
# The cache directory. This can get huge. Better to use a Docker volume pointing here!
88+
# Set to 32gb which should be enough
89+
echo "proxy_cache_path /docker_mirror_cache levels=1:2 max_size=$CACHE_MAX_SIZE inactive=60d keys_zone=cache:10m use_temp_path=off;" > /etc/nginx/conf.d/cache_max_size.conf
90+
8491
# normally use non-debug version of nginx
8592
NGINX_BIN="nginx"
8693

nginx.conf

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ http {
4242
keepalive_timeout 300;
4343
gzip off;
4444

45-
# The cache directory. This can get huge. Better to use a Docker volume pointing here!
46-
# Set to 32gb which should be enough
47-
proxy_cache_path /docker_mirror_cache levels=1:2 max_size=32g inactive=60d keys_zone=cache:10m use_temp_path=off;
48-
4945
# Just in case you want to rewrite some hosts. Default maps directly.
5046
map $host $targetHost {
5147
hostnames;
@@ -93,6 +89,8 @@ http {
9389
default "DID_NOT_MATCH_PATH";
9490
}
9591

92+
include /etc/nginx/conf.d/*.conf;
93+
9694

9795
# The proxy director layer, listens on 3128
9896
server {

0 commit comments

Comments
 (0)