Skip to content

The open-source app everyone uses to manage agents at work

ci: harden Docker image build workflow against lockfile drift and runner disk exhaustion (#10142)

Devin Foley14f20be92b86
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index ae41e26851..d108ffcfc9 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -22,6 +22,62 @@ jobs:
- name: Checkout
uses: actions/checkout@v7
+ - name: Setup pnpm
+ uses: pnpm/action-setup@v6
+ with:
+ version: 9.15.4
+ run_install: false
+
+ # No dependency cache here: this workflow publishes release images, and
+ # restoring a shared Actions cache into the build inputs would let a
+ # poisoned cache entry reach the published artifact.
+ - name: Setup Node.js
+ uses: actions/setup-node@v7
+ with:
+ node-version: 20
+
+ - name: Refresh lockfile for Docker build context
+ run: |
+ set -euo pipefail
+ pnpm install --lockfile-only --ignore-scripts --no-frozen-lockfile
+
+ changed="$(git status --porcelain)"
+ if [ -z "$changed" ]; then
+ echo "Lockfile already matches package metadata."
+ exit 0
+ fi
+
+ if printf '%s\n' "$changed" | grep -Fvq ' pnpm-lock.yaml'; then
+ echo "Unexpected files changed during lockfile refresh:"
+ echo "$changed"
+ exit 1
+ fi
+
+ echo "Using refreshed pnpm-lock.yaml in the Docker build context."
+
+ - name: Free runner disk
+ run: |
+ set -euo pipefail
+ echo "Disk before cleanup:"
+ df -h
+
+ pnpm store prune || true
+ sudo apt-get clean || true
+ sudo rm -rf \
+ /usr/share/dotnet \
+ /usr/share/swift \
+ /usr/local/lib/android \
+ /usr/local/share/boost \
+ /usr/local/share/powershell \
+ /opt/ghc \
+ /opt/hostedtoolcache/CodeQL \
+ /opt/hostedtoolcache/PyPy \
+ /opt/hostedtoolcache/Ruby || true
+ docker system prune -af || true
+
+ echo "Disk after cleanup:"
+ df -h
+
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with: