[CI] clean docker cache for neuron (#4441)

This commit is contained in:
Simon Mo 2024-04-28 16:32:07 -07:00 committed by GitHub
parent bf480c5302
commit 03dd7d52bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,20 @@ set -e
# Try building the docker image
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 763104351884.dkr.ecr.us-west-2.amazonaws.com
# prune old image and containers to save disk space, and only once a day
# by using a timestamp file in tmp.
if [ -f /tmp/neuron-docker-build-timestamp ]; then
last_build=$(cat /tmp/neuron-docker-build-timestamp)
current_time=$(date +%s)
if [ $((current_time - last_build)) -gt 86400 ]; then
docker system prune -f
echo $current_time > /tmp/neuron-docker-build-timestamp
fi
else
echo $(date +%s) > /tmp/neuron-docker-build-timestamp
fi
docker build -t neuron -f Dockerfile.neuron .
# Setup cleanup