From e03d3bee100bab4ac4cf6e093b507211987245eb Mon Sep 17 00:00:00 2001 From: Marko Vejnovic Date: Wed, 12 Nov 2025 14:40:12 -0800 Subject: [PATCH] ci(ENG-21502): Fix sccache not working inside Docker (#24597) --- .buildkite/Dockerfile | 14 ++++++++++++++ scripts/bootstrap.sh | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/.buildkite/Dockerfile b/.buildkite/Dockerfile index 55e45ccdff..033aec633d 100644 --- a/.buildkite/Dockerfile +++ b/.buildkite/Dockerfile @@ -133,6 +133,20 @@ RUN ARCH=$(if [ "$TARGETARCH" = "arm64" ]; then echo "arm64"; else echo "amd64"; RUN mkdir -p /var/cache/buildkite-agent /var/log/buildkite-agent /var/run/buildkite-agent /etc/buildkite-agent /var/lib/buildkite-agent/cache/bun +# The following is necessary to configure buildkite to use a stable +# checkout directory. sccache hashes absolute paths into its cache keys, +# so if buildkite uses a different checkout path each time (which it does +# by default), sccache will be useless. +RUN mkdir -p -m 755 /var/lib/buildkite-agent/hooks && \ + cat <<'EOF' > /var/lib/buildkite-agent/hooks/environment +#!/bin/sh +set -efu + +export BUILDKITE_BUILD_CHECKOUT_PATH=/var/lib/buildkite-agent/build +EOF + +RUN chmod 744 /var/lib/buildkite-agent/hooks/environment + COPY ../*/agent.mjs /var/bun/scripts/ ENV BUN_INSTALL_CACHE=/var/lib/buildkite-agent/cache/bun diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index ead3de99c8..7bc2a53ad6 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -1392,6 +1392,10 @@ create_buildkite_user() { create_file "$file" done + # The following is necessary to configure buildkite to use a stable + # checkout directory. sccache hashes absolute paths into its cache keys, + # so if buildkite uses a different checkout path each time (which it does + # by default), sccache will be useless. local opts=$- set -ef