Skip to content

Commit fd7fb6b

Browse files
authored
feat(entrypoint): set cache valid time from env (#21)
* Add CACHE_DEFAULT_TIME env * Fix comment string * Use env CACHE_VALID_TIME * Update comment
1 parent 2cb5391 commit fd7fb6b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ CACHE_MAX_SIZE=${CACHE_MAX_SIZE:-32g}
104104
# Set to 32gb which should be enough
105105
echo "proxy_cache_path /docker_mirror_cache 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_MANAGER_SLEEP:-50ms};" > /etc/nginx/conf.d/cache_max_size.conf
106106

107+
# Set Docker Registry cache valid time, by default, 60 day ('60d')
108+
CACHE_VALID_TIME=${CACHE_VALID_TIME:-60d}
109+
110+
# Set default cache valid time for 200 and 205 response.
111+
sed -i "/# Cache all 200, 206 for 60 days default./a\ proxy_cache_valid 200 206 ${CACHE_VALID_TIME};" /etc/nginx/nginx.conf
112+
107113
# Manifest caching configuration. We generate config based on the environment vars.
108114
echo -n "" >/etc/nginx/nginx.manifest.caching.config.conf
109115

nginx.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,7 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
242242
proxy_cache_lock on;
243243
proxy_cache_lock_timeout 880s;
244244

245-
# Cache all 200, 206 for 60 days.
246-
proxy_cache_valid 200 206 60d;
245+
# Cache all 200, 206 for 60 days default.
247246

248247
# Some extra settings to maximize cache hits and efficiency
249248
proxy_force_ranges on;

0 commit comments

Comments
 (0)