fix: prune stale Docker images and build cache after each deploy
Adds a post-deploy step that removes Docker images and build cache older than 24 hours. Prevents the gradual disk bloat from repeated docker compose --build invocations (was 71GB on the Pi).
This commit is contained in:
@@ -70,10 +70,14 @@ deploy() {
|
|||||||
./ "$PI_USER@$host:$path"
|
./ "$PI_USER@$host:$path"
|
||||||
|
|
||||||
# Rebuild
|
# Rebuild
|
||||||
echo " [3/3] Building and restarting..."
|
echo " [3/4] Building and restarting..."
|
||||||
# Clean up stale renamed containers left by failed recreates (e.g. "d420a6c00439_backspace")
|
# Clean up stale renamed containers left by failed recreates (e.g. "d420a6c00439_backspace")
|
||||||
ssh "$PI_USER@$host" "cd $path && docker rm -f \$(docker ps -aq --filter 'name=_backspace' 2>/dev/null) 2>/dev/null; docker compose up -d --build"
|
ssh "$PI_USER@$host" "cd $path && docker rm -f \$(docker ps -aq --filter 'name=_backspace' 2>/dev/null) 2>/dev/null; docker compose up -d --build"
|
||||||
|
|
||||||
|
# Prune old images and build cache to prevent disk bloat
|
||||||
|
echo " [4/4] Pruning stale Docker data..."
|
||||||
|
ssh "$PI_USER@$host" "docker image prune -af --filter 'until=24h' 2>/dev/null; docker builder prune -af --filter 'until=24h' 2>/dev/null" || true
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo " Done: $name"
|
echo " Done: $name"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user