Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Docker cleanup to preserve caching #6631

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/ghcr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ jobs:
outputs:
hash_from_app_image: ${{ steps.get_hash_in_app_image.outputs.hash_from_app_image }}
steps:
- name: Check initial disk space
run: |
echo "=== Initial Disk Space Overview ==="
df -h
echo
echo "=== Initial Docker Space Usage ==="
docker system df
echo
echo "=== Largest Files/Directories ==="
sudo du -h / 2>/dev/null | sort -rh | head -n 20

- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
Expand All @@ -62,6 +73,31 @@ jobs:
if: "github.event.pull_request.head.repo.fork"
run: |
./containers/build.sh -i openhands -o ${{ github.repository_owner }} --load

- name: Check disk space after build
run: |
echo "=== Disk Space After Build ==="
df -h
echo
echo "=== Docker Space Usage After Build ==="
docker system df
echo
echo "=== Largest Files/Directories ==="
sudo du -h / 2>/dev/null | sort -rh | head -n 20

- name: Clean up unused Docker resources
run: |
echo "=== Cleaning up unused Docker resources ==="
# Remove only dangling images (untagged)
docker image prune -f
# Remove containers that have exited more than 1 hour ago
docker container prune -f --filter "until=1h"
# Remove only unused volumes
docker volume prune -f
echo
echo "=== Docker Space Usage After Cleanup ==="
docker system df

- name: Get hash in App Image
id: get_hash_in_app_image
run: |
Expand All @@ -75,6 +111,30 @@ jobs:
echo "hash_from_app_image=$hash_from_app_image" >> $GITHUB_OUTPUT
echo "Hash from app image: $hash_from_app_image"

- name: Check disk space after hash verification
run: |
echo "=== Disk Space After Hash Verification ==="
df -h
echo
echo "=== Docker Space Usage After Hash Verification ==="
docker system df
echo
echo "=== Largest Files/Directories ==="
sudo du -h / 2>/dev/null | sort -rh | head -n 20

- name: Clean up unused Docker resources after hash verification
run: |
echo "=== Cleaning up unused Docker resources ==="
# Remove only dangling images (untagged)
docker image prune -f
# Remove containers that have exited more than 1 hour ago
docker container prune -f --filter "until=1h"
# Remove only unused volumes
docker volume prune -f
echo
echo "=== Docker Space Usage After Cleanup ==="
docker system df

# Builds the runtime Docker images
ghcr_build_runtime:
name: Build Image
Expand Down