File tree 4 files changed +26
-3
lines changed
4 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,8 @@ ENV DEBUG="false"
75
75
ENV DEBUG_HUB="false"
76
76
# Enable nginx debugging mode; this uses nginx-debug binary and enabled debug logging, which is VERY verbose so separate setting
77
77
ENV DEBUG_NGINX="false"
78
+ # Enable slow caching tier; this allows caching in a secondary cache path on e.g a larger slower disk; for known URIs defined in SLOW_TIER_URIS
79
+ ENV SLOW_TIER_ENABLED="false"
78
80
79
81
# Manifest caching tiers. Disabled by default, to mimick 0.4/0.5 behaviour.
80
82
# Setting it to true enables the processing of the ENVs below.
Original file line number Diff line number Diff line change @@ -105,7 +105,28 @@ CACHE_DIRECTORY=${CACHE_DIRECTORY:-/docker_mirror_cache}
105
105
106
106
# The cache directory. This can get huge. Better to use a Docker volume pointing here!
107
107
# Set to 32gb which should be enough
108
- echo " proxy_cache_path ${CACHE_DIRECTORY} levels=1:2 max_size=$CACHE_MAX_SIZE min_free=${CACHE_MIN_FREE:- 1g} inactive=${CACHE_INACTIVE_TIME:- 60d} keys_zone=cache:15m use_temp_path=off manager_threshold=${CACHE_MANAGER_THRESHOLD:- 1000ms} manager_sleep=${CACHE_MANAGER_SLEEP:- 250ms} manager_files=${CACHE_MANAGER_FILES:- 100} loader_files=${CACHE_LOADER_FILES:- 100} loader_threshold=${CACHE_LOADER_THRESHOLD:- 200ms} loader_sleep=${CACHE_LOADER_SLEEP:- 50ms} ;" > /etc/nginx/conf.d/cache_max_size.conf
108
+ echo " proxy_cache_path ${CACHE_DIRECTORY} levels=1:2 max_size=${CACHE_MAX_SIZE:- 15g} min_free=${CACHE_MIN_FREE:- 1g} inactive=${CACHE_INACTIVE_TIME:- 60d} keys_zone=cache:${CACHE_KEYS_ZONE:- 15m} use_temp_path=off manager_threshold=${CACHE_MANAGER_THRESHOLD:- 1000ms} manager_sleep=${CACHE_MANAGER_SLEEP:- 250ms} manager_files=${CACHE_MANAGER_FILES:- 100} loader_files=${CACHE_LOADER_FILES:- 100} loader_threshold=${CACHE_LOADER_THRESHOLD:- 200ms} loader_sleep=${CACHE_LOADER_SLEEP:- 50ms} ;" > /etc/nginx/conf.d/cache_max_size.conf
109
+
110
+ if [[ " a${SLOW_TIER_ENABLED} " == " atrue" ]]; then
111
+ {
112
+ echo " "
113
+ echo " proxy_cache_path ${SLOW_CACHE_DIRECTORY} levels=1:2 max_size=${SLOW_CACHE_MAX_SIZ:- 15g} min_free=${SLOW_CACHE_MIN_FREE:- 1g} inactive=${SLOW_CACHE_INACTIVE_TIME:- 120d} keys_zone=slow_cache:${SLOW_CACHE_KEYS_ZONE:- 150m} use_temp_path=off manager_threshold=${SLOW_CACHE_MANAGER_THRESHOLD:- 1000ms} manager_sleep=${SLOW_CACHE_MANAGER_SLEEP:- 250ms} manager_files=${SLOW_CACHE_MANAGER_FILES:- 100} loader_files=${SLOW_CACHE_LOADER_FILES:- 100} loader_threshold=${SLOW_CACHE_LOADER_THRESHOLD:- 200ms} loader_sleep=${SLOW_CACHE_LOADER_SLEEP:- 50ms} ;"
114
+ echo " "
115
+ echo " map \$ request_uri \$ cache {"
116
+ echo " ${SLOW_TIER_URIS% ;} ;" | sed ' s/;/ slow_cache;\n /g'
117
+ echo " default cache;"
118
+ echo " }"
119
+ echo " "
120
+ } >> /etc/nginx/conf.d/cache_max_size.conf; else
121
+
122
+ {
123
+ echo " "
124
+ echo " map \$ request_uri \$ cache {"
125
+ echo " default cache;"
126
+ echo " }"
127
+ echo " "
128
+ } >> /etc/nginx/conf.d/cache_max_size.conf;
129
+ fi
109
130
110
131
# Clear the cache directory if the free space is less than the threshold
111
132
# Get the available space in the directory
Original file line number Diff line number Diff line change @@ -316,7 +316,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
316
316
317
317
# nginx goes to fetch the value from the upstream Location header
318
318
proxy_pass $orig_loc ;
319
- proxy_cache cache;
319
+ proxy_cache $ cache ;
320
320
# But we store the result with the cache key of the original request URI
321
321
# so that future clients don't need to follow the redirect too
322
322
proxy_cache_key $original_uri$slice_range ;
Original file line number Diff line number Diff line change 2
2
add_header X-Docker-Registry-Proxy-Cache-Upstream-Status "$upstream_cache_status";
3
3
add_header X-Docker-Registry-Proxy-Cache-Type "$docker_proxy_request_type";
4
4
proxy_pass https://$targetHost;
5
- proxy_cache cache;
5
+ proxy_cache $ cache;
6
6
slice 4m;
7
7
proxy_cache_key $uri$slice_range;
8
8
proxy_set_header Range $slice_range;
You can’t perform that action at this time.
0 commit comments