feat: clear out docker builder cache once a day

There have been a number of tickets in the past - most recently #7061 - covering the fact that Dokku doesn't clean up disk utilization. The underlying issue is that Docker uses build cache that cannot be cleaned up in a targeted way - and usually doesn't even respect the builder gc settings in a way that makes sense. In fact, the computed disk space does not line up with actual disk utilization, causing it to be a mystery to anyone investigating the underlying problem.

This change introduces a cron-based mechanism that cleans up disk once a day. Cleaning up more often would potentially cause issues during a build if for some reason the prune and an app deploy happened at the same time - its not clear if there is a lock on build cache usage - so cleaning up after hours once a day is a decent tradeoff.

In the future, this setting may be modifiable, but it works well for now.

Closes #7061
This commit is contained in:
Jose Diaz-Gonzalez
2024-09-22 21:02:20 -04:00
parent e1c95ffaa7
commit 097fb4d819
3 changed files with 60 additions and 1 deletions

View File

@@ -0,0 +1,4 @@
PATH=/usr/local/bin:/usr/bin:/bin
SHELL=/bin/bash
5 4 * * * root /usr/local/bin/docker builder prune >>/var/log/dokku/builder-prune.log 2>&1