Skip to content

Commit 2fb1ec5

Browse files
committed
fix(ci): free up space in container before docker build
fix(ci): pin unbuntu version of `docker-publish` to `24.04` (was `latest`)
1 parent f8075d1 commit 2fb1ec5

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

.github/workflows/docker-publish.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ env:
2121
# github.repository as <account>/<repo>
2222
IMAGE_NAME: emcie-co/parlant
2323

24-
2524
jobs:
2625
build:
2726

28-
runs-on: ubuntu-latest
27+
runs-on: ubuntu-24.04
2928
permissions:
3029
contents: read
3130
packages: write
@@ -71,6 +70,12 @@ jobs:
7170
tags: |
7271
type=raw,value=edge
7372
73+
# Remove unused packages and directories to free up space for a (possibly large) Docker build
74+
- name: Cleanup disk space
75+
run: |
76+
chmod +x ./scripts/ci/github_action_ubuntu_2404_free_space.sh
77+
./scripts/ci/github_action_ubuntu_2404_free_space.sh
78+
7479
# Build and push Docker image with Buildx (don't push on PR)
7580
# https://github.com/docker/build-push-action
7681
- name: Build and push Docker image
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/sh
2+
3+
# Print initial disk space usage
4+
df -h / | awk 'NR==2 {printf "Before cleanup: %s used, %s free\n", $3, $4}'
5+
6+
# Remove docker images
7+
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true
8+
9+
# Remove development toolchains and SDK directories
10+
sudo rm -rf \
11+
/opt/hostedtoolcache/* \
12+
/usr/local/lib/android \
13+
/usr/share/dotnet \
14+
/usr/local/share/powershell \
15+
/usr/share/swift \
16+
/opt/ghc \
17+
/usr/local/.ghcup \
18+
/usr/lib/jvm \
19+
/usr/local/julia* \
20+
/usr/local/n \
21+
/usr/local/share/chromium \
22+
/usr/local/share/vcpkg \
23+
>/dev/null 2>&1 || true
24+
25+
# Remove unnecessary packages
26+
sudo apt-get remove -y \
27+
azure-cli \
28+
google-cloud-sdk \
29+
firefox \
30+
google-chrome-stable \
31+
microsoft-edge-stable \
32+
mysql* \
33+
mongodb-org* \
34+
dotnet* \
35+
php* \
36+
>/dev/null 2>&1 || true
37+
38+
# Clean up package system
39+
sudo apt-get autoremove -y >/dev/null 2>&1
40+
sudo apt-get clean -y >/dev/null 2>&1
41+
42+
# Clean up package caches and data
43+
sudo rm -rf \
44+
/var/lib/docker/* \
45+
/var/lib/gems/* \
46+
/var/lib/apt/lists/* \
47+
/var/cache/* \
48+
/var/lib/snapd \
49+
>/dev/null 2>&1 || true
50+
51+
# Print final disk space usage and difference
52+
df -h / | awk -v before="$(df -h / | awk 'NR==2 {print $3}')" \
53+
'NR==2 {printf "After cleanup: %s used, %s free (freed %s)\n",
54+
$3, $4, substr(before,1,length(before)-1) - substr($3,1,length($3)-1) "G"}'

0 commit comments

Comments
 (0)