From fcba4f8056239f6d9c007c78cab8b2ad781cf02e Mon Sep 17 00:00:00 2001 From: Tim Pilius Date: Mon, 6 May 2024 16:19:25 -0400 Subject: [PATCH] Adding support for the new min_free parameter, so that nginx will automatically prune files once the minimum free space has been exceeded. --- Dockerfile | 3 ++- overlay/etc/nginx/conf.d/20_proxy_cache_path.conf | 2 +- overlay/hooks/entrypoint-pre.d/10_setup.sh | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 54a6495..1084dcf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ ENV GENERICCACHE_VERSION=2 \ WEBUSER=www-data \ CACHE_INDEX_SIZE=500m \ CACHE_DISK_SIZE=1000g \ + MIN_FREE_DISK=100g \ CACHE_MAX_AGE=3560d \ CACHE_SLICE_SIZE=1m \ UPSTREAM_DNS="8.8.8.8 8.8.4.4" \ @@ -27,7 +28,7 @@ RUN rm /etc/nginx/sites-enabled/* /etc/nginx/stream-enabled/* ;\ rm /etc/nginx/conf.d/gzip.conf ;\ chmod 754 /var/log/tallylog ; \ id -u ${WEBUSER} &> /dev/null || adduser --system --home /var/www/ --no-create-home --shell /bin/false --group --disabled-login ${WEBUSER} ;\ - chmod 755 /scripts/* ;\ + chmod 755 /scripts/* ;\ mkdir -m 755 -p /data/cache ;\ mkdir -m 755 -p /data/info ;\ mkdir -m 755 -p /data/logs ;\ diff --git a/overlay/etc/nginx/conf.d/20_proxy_cache_path.conf b/overlay/etc/nginx/conf.d/20_proxy_cache_path.conf index e1a990b..75f4f02 100644 --- a/overlay/etc/nginx/conf.d/20_proxy_cache_path.conf +++ b/overlay/etc/nginx/conf.d/20_proxy_cache_path.conf @@ -1 +1 @@ -proxy_cache_path /data/cache/cache levels=2:2 keys_zone=generic:CACHE_INDEX_SIZE inactive=CACHE_MAX_AGE max_size=CACHE_DISK_SIZE loader_files=1000 loader_sleep=50ms loader_threshold=300ms use_temp_path=off; +proxy_cache_path /data/cache/cache levels=2:2 keys_zone=generic:CACHE_INDEX_SIZE inactive=CACHE_MAX_AGE max_size=CACHE_DISK_SIZE min_free=MIN_FREE_DISK loader_files=1000 loader_sleep=50ms loader_threshold=300ms use_temp_path=off; diff --git a/overlay/hooks/entrypoint-pre.d/10_setup.sh b/overlay/hooks/entrypoint-pre.d/10_setup.sh index 894b49f..039f645 100644 --- a/overlay/hooks/entrypoint-pre.d/10_setup.sh +++ b/overlay/hooks/entrypoint-pre.d/10_setup.sh @@ -13,6 +13,7 @@ echo "worker_processes ${NGINX_WORKER_PROCESSES};" > /etc/nginx/workers.conf sed -i "s/^user .*/user ${WEBUSER};/" /etc/nginx/nginx.conf sed -i "s/CACHE_INDEX_SIZE/${CACHE_INDEX_SIZE}/" /etc/nginx/conf.d/20_proxy_cache_path.conf sed -i "s/CACHE_DISK_SIZE/${CACHE_DISK_SIZE}/" /etc/nginx/conf.d/20_proxy_cache_path.conf +sed -i "s/MIN_FREE_DISK/${MIN_FREE_DISK}/" /etc/nginx/conf.d/20_proxy_cache_path.conf sed -i "s/CACHE_MAX_AGE/${CACHE_MAX_AGE}/" /etc/nginx/conf.d/20_proxy_cache_path.conf sed -i "s/CACHE_MAX_AGE/${CACHE_MAX_AGE}/" /etc/nginx/sites-available/cache.conf.d/root/20_cache.conf sed -i "s/slice 1m;/slice ${CACHE_SLICE_SIZE};/" /etc/nginx/sites-available/cache.conf.d/root/20_cache.conf