Skip to content

Commit a25db0e

Browse files
committed
fix: Add disk space cleanup to all Docker build workflows
Prevents 'No space left on device' errors in GitHub Actions by freeing ~10-14GB: Modified workflows: - ci.yml (main CI/CD pipeline) - k8s-deploy-staging.yml (staging deployment) - k8s-deploy-production.yml (production deployment) - dev-environment-ci.yml (already fixed in previous commit) Added test workflow: - test-disk-cleanup.yml (manual validation workflow) Each cleanup step: 1. Removes pre-installed tools: .NET (~3-4GB), Android SDK (~3-4GB), GHC (~1-2GB), CodeQL (~1-2GB) 2. Cleans Docker system cache (~1-2GB) 3. Reports disk space before/after Validation performed: ✓ All YAML syntax valid ✓ Cleanup runs BEFORE Docker builds in all workflows ✓ Industry-standard pattern (used by Kubernetes, TensorFlow, etc.) Fixes: https://github.com/manavgup/rag_modulo/actions/runs/18222106174/job/51884221970
1 parent 7133e59 commit a25db0e

File tree

4 files changed

+129
-0
lines changed

4 files changed

+129
-0
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,23 @@ jobs:
146146
steps:
147147
- uses: actions/checkout@v4
148148

149+
- name: Free up disk space
150+
run: |
151+
echo "Disk space before cleanup:"
152+
df -h
153+
154+
# Remove unnecessary packages and files
155+
sudo rm -rf /usr/share/dotnet
156+
sudo rm -rf /usr/local/lib/android
157+
sudo rm -rf /opt/ghc
158+
sudo rm -rf /opt/hostedtoolcache/CodeQL
159+
160+
# Clean docker system
161+
docker system prune -af --volumes || true
162+
163+
echo "Disk space after cleanup:"
164+
df -h
165+
149166
- name: Set up Docker Buildx
150167
uses: docker/setup-buildx-action@v2
151168

.github/workflows/k8s-deploy-production.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ jobs:
3939
- name: Checkout code
4040
uses: actions/checkout@v4
4141

42+
- name: Free up disk space
43+
run: |
44+
echo "Disk space before cleanup:"
45+
df -h
46+
47+
# Remove unnecessary packages and files
48+
sudo rm -rf /usr/share/dotnet
49+
sudo rm -rf /usr/local/lib/android
50+
sudo rm -rf /opt/ghc
51+
sudo rm -rf /opt/hostedtoolcache/CodeQL
52+
53+
# Clean docker system
54+
docker system prune -af --volumes || true
55+
56+
echo "Disk space after cleanup:"
57+
df -h
58+
4259
- name: Set up Docker Buildx
4360
uses: docker/setup-buildx-action@v3
4461

.github/workflows/k8s-deploy-staging.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ jobs:
2828
- name: Checkout code
2929
uses: actions/checkout@v4
3030

31+
- name: Free up disk space
32+
run: |
33+
echo "Disk space before cleanup:"
34+
df -h
35+
36+
# Remove unnecessary packages and files
37+
sudo rm -rf /usr/share/dotnet
38+
sudo rm -rf /usr/local/lib/android
39+
sudo rm -rf /opt/ghc
40+
sudo rm -rf /opt/hostedtoolcache/CodeQL
41+
42+
# Clean docker system
43+
docker system prune -af --volumes || true
44+
45+
echo "Disk space after cleanup:"
46+
df -h
47+
3148
- name: Set up Docker Buildx
3249
uses: docker/setup-buildx-action@v3
3350

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Test Disk Cleanup Strategy
2+
3+
on:
4+
workflow_dispatch: # Manual trigger only
5+
6+
jobs:
7+
validate-disk-cleanup:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Show initial disk space
12+
run: |
13+
echo "=== Initial Disk Space ==="
14+
df -h
15+
echo ""
16+
echo "=== Directory Sizes Before Cleanup ==="
17+
echo "dotnet: $(sudo du -sh /usr/share/dotnet 2>/dev/null || echo 'N/A')"
18+
echo "android: $(sudo du -sh /usr/local/lib/android 2>/dev/null || echo 'N/A')"
19+
echo "ghc: $(sudo du -sh /opt/ghc 2>/dev/null || echo 'N/A')"
20+
echo "CodeQL: $(sudo du -sh /opt/hostedtoolcache/CodeQL 2>/dev/null || echo 'N/A')"
21+
22+
- name: Test disk cleanup
23+
run: |
24+
echo "=== Performing Cleanup ==="
25+
26+
# Remove unnecessary packages and files
27+
sudo rm -rf /usr/share/dotnet
28+
sudo rm -rf /usr/local/lib/android
29+
sudo rm -rf /opt/ghc
30+
sudo rm -rf /opt/hostedtoolcache/CodeQL
31+
32+
# Clean docker system
33+
docker system prune -af --volumes || true
34+
35+
- name: Show disk space after cleanup
36+
run: |
37+
echo "=== Disk Space After Cleanup ==="
38+
df -h
39+
echo ""
40+
41+
# Calculate freed space
42+
echo "=== Verification ==="
43+
if [ ! -d "/usr/share/dotnet" ]; then
44+
echo "✓ dotnet removed"
45+
fi
46+
if [ ! -d "/usr/local/lib/android" ]; then
47+
echo "✓ android removed"
48+
fi
49+
if [ ! -d "/opt/ghc" ]; then
50+
echo "✓ ghc removed"
51+
fi
52+
if [ ! -d "/opt/hostedtoolcache/CodeQL" ]; then
53+
echo "✓ CodeQL removed"
54+
fi
55+
56+
- name: Test Docker build with freed space
57+
run: |
58+
echo "=== Testing Docker Build ==="
59+
60+
# Create a simple test Dockerfile
61+
cat > Dockerfile << 'EOF'
62+
FROM python:3.12-slim
63+
RUN apt-get update && apt-get install -y curl
64+
RUN pip install fastapi uvicorn
65+
EOF
66+
67+
# Try to build
68+
docker build -t test-image .
69+
70+
echo "✓ Docker build succeeded with available space"
71+
72+
- name: Summary
73+
run: |
74+
echo ""
75+
echo "=== Summary ==="
76+
echo "Disk cleanup completed successfully!"
77+
echo "Docker builds can proceed without space issues."
78+
df -h / | grep -E "Filesystem|/$"

0 commit comments

Comments
 (0)