add options to customise cache timers

pull/105/head
Hisham 2021-08-04 09:09:35 +10:00
parent 2456b35b5c
commit 47af7fa5d8
2 changed files with 11 additions and 4 deletions

View File

@ -99,10 +99,17 @@ echo "error_log /var/log/nginx/error.log warn;" > /etc/nginx/error.log.debug.wa
# Set Docker Registry cache size, by default, 32 GB ('32g') # Set Docker Registry cache size, by default, 32 GB ('32g')
CACHE_MAX_SIZE=${CACHE_MAX_SIZE:-32g} CACHE_MAX_SIZE=${CACHE_MAX_SIZE:-32g}
# Set Docker Registry cache max age, by default, 60 days ('60d')
CACHE_MAX_AGE=${CACHE_MAX_AGE:-60d}
# The cache directory. This can get huge. Better to use a Docker volume pointing here! # The cache directory. This can get huge. Better to use a Docker volume pointing here!
# Set to 32gb which should be enough # Set to 32gb which should be enough
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 echo "proxy_cache_path /docker_mirror_cache levels=1:2 max_size=$CACHE_MAX_SIZE inactive=$CACHE_MAX_AGE keys_zone=cache:10m use_temp_path=off;" > /etc/nginx/conf.d/proxy_cache_path.conf
# Set Docker Registry cache valid duration, by default, 60 days ('60d')
CACHE_VALIDITY_PERIOD=${CACHE_VALIDITY_PERIOD:-60d}
# Cache all 200, 206 for CACHE_VALIDITY_PERIOD.
echo "proxy_cache_valid 200 206 $CACHE_VALIDITY_PERIOD;" > /etc/nginx/conf.d/proxy_cache_valid.conf
# Manifest caching configuration. We generate config based on the environment vars. # Manifest caching configuration. We generate config based on the environment vars.
echo -n "" >/etc/nginx/nginx.manifest.caching.config.conf echo -n "" >/etc/nginx/nginx.manifest.caching.config.conf

View File

@ -79,7 +79,7 @@ http {
gzip off; gzip off;
# Entrypoint generates the proxy_cache_path here, so it is configurable externally. # Entrypoint generates the proxy_cache_path here, so it is configurable externally.
include /etc/nginx/conf.d/cache_max_size.conf; include /etc/nginx/conf.d/proxy_cache_path.conf;
# Just in case you want to rewrite some hosts. Default maps directly. # Just in case you want to rewrite some hosts. Default maps directly.
map $host $targetHost { map $host $targetHost {
@ -232,8 +232,8 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
proxy_cache_lock on; proxy_cache_lock on;
proxy_cache_lock_timeout 880s; proxy_cache_lock_timeout 880s;
# Cache all 200, 206 for 60 days. # Entrypoint generates the proxy_cache_valid here, so it is configurable externally.
proxy_cache_valid 200 206 60d; include /etc/nginx/conf.d/proxy_cache_valid.conf;
# Some extra settings to maximize cache hits and efficiency # Some extra settings to maximize cache hits and efficiency
proxy_force_ranges on; proxy_force_ranges on;