docker: improve cleanup of docker space in CI

Mimic `lnd`s cleanup of docker space in CI by adding a new clean-space
job which removes the same docker related artifacts as `lnd` does prior
to running the rest of the docker.yml jobs.
This commit is contained in:
Viktor Torstensson 2026-07-01 12:53:07 +02:00
parent 08934deeef
commit 4e72e798e6
No known key found for this signature in database
GPG key ID: 961CC8259AE675D4
2 changed files with 49 additions and 1 deletions

View file

@ -0,0 +1,48 @@
name: "Clean up runner disk space"
description: "Removes large, non-essential toolsets to free up disk space."
runs:
using: "composite"
steps:
- name: Free up disk space
shell: bash
run: |
echo "Removing large toolsets to free up disk space..."
echo "Disk space before cleanup:"
df -h
# Remove large language/runtime toolsets that aren't needed for the
# Docker image build on the GitHub-hosted runner.
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /usr/share/swift
sudo rm -rf /usr/local/julia*
sudo rm -rf /opt/hostedtoolcache
# Reclaim any Docker images that may already be present on the runner.
docker image prune -a -f || true
# Remove large apt packages and clean related caches.
sudo apt-get remove -y \
'^aspnetcore-.*' \
'^dotnet-.*' \
'^llvm-.*' \
'php.*' \
'^mongodb-.*' \
'^mysql-.*' \
azure-cli \
google-chrome-stable \
firefox \
powershell \
mono-devel \
libgl1-mesa-dri 2>/dev/null || true
sudo apt-get autoremove -y
sudo apt-get clean
# Remove additional large caches and tool directories.
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
echo "Disk space after cleanup:"
df -h

View file

@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: cleanup space - name: cleanup space
run: rm -rf /opt/hostedtoolcache uses: ./.github/actions/cleanup-space
- name: Set up QEMU - name: Set up QEMU
uses: lightninglabs/gh-actions/setup-qemu-action@2021.01.25.00 uses: lightninglabs/gh-actions/setup-qemu-action@2021.01.25.00