mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
4a776d0ca7
This allows users to configure the buildkit GC. The following enables the default GC: ``` { "builder": { "gc": { "enabled": true } } } ``` The default GC policy has a simple config: ``` { "builder": { "gc": { "enabled": true, "defaultKeepStorage": "30GB" } } } ``` A custom GC policy can be used instead by specifying a list of cache prune rules: ``` { "builder": { "gc": { "enabled": true, "policy": [ {"keepStorage": "512MB", "filter": ["unused-for=1400h"]]}, {"keepStorage": "30GB", "all": true} ] } } } ``` Signed-off-by: Tibor Vass <tibor@docker.com>
17 lines
343 B
Go
17 lines
343 B
Go
// +build !windows
|
|
|
|
package worker
|
|
|
|
import (
|
|
"syscall"
|
|
)
|
|
|
|
func detectDefaultGCCap(root string) int64 {
|
|
var st syscall.Statfs_t
|
|
if err := syscall.Statfs(root, &st); err != nil {
|
|
return defaultCap
|
|
}
|
|
diskSize := int64(st.Bsize) * int64(st.Blocks) // nolint unconvert
|
|
avail := diskSize / 10
|
|
return (avail/(1<<30) + 1) * 1e9 // round up
|
|
}
|