From 9236902ade1ffbaf3250725ffa423c7205f2464b Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 3 Apr 2026 20:33:27 +0000 Subject: [PATCH 1/3] chore(docker): speed up builds with BuildKit caches Co-authored-by: Michael Sukkarieh --- .github/workflows/pr-gate.yml | 5 +++++ Dockerfile | 28 +++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-gate.yml b/.github/workflows/pr-gate.yml index de59790f0..1d54fc0b9 100644 --- a/.github/workflows/pr-gate.yml +++ b/.github/workflows/pr-gate.yml @@ -17,8 +17,13 @@ jobs: with: submodules: "true" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build Docker image id: build uses: docker/build-push-action@v6 with: context: . + cache-from: type=gha,scope=pr-gate + cache-to: type=gha,mode=max,scope=pr-gate diff --git a/Dockerfile b/Dockerfile index 66bc3489c..d22c1fea9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# syntax=docker/dockerfile:1 +# syntax=docker/dockerfile:1.7 # ------ Global scope variables ------ # Set of global build arguments. @@ -24,9 +24,13 @@ FROM go-alpine AS zoekt-builder RUN apk add --no-cache ca-certificates WORKDIR /zoekt COPY vendor/zoekt/go.mod vendor/zoekt/go.sum ./ -RUN go mod download +RUN --mount=type=cache,id=sourcebot-go-mod-cache,target=/go/pkg/mod \ + --mount=type=cache,id=sourcebot-go-build-cache,target=/root/.cache/go-build \ + go mod download COPY vendor/zoekt ./ -RUN CGO_ENABLED=0 GOOS=linux go build -o /cmd/ ./cmd/... +RUN --mount=type=cache,id=sourcebot-go-mod-cache,target=/go/pkg/mod \ + --mount=type=cache,id=sourcebot-go-build-cache,target=/root/.cache/go-build \ + CGO_ENABLED=0 GOOS=linux go build -o /cmd/ ./cmd/... # ------------------------- # ------ Build shared libraries ------ @@ -40,10 +44,14 @@ COPY ./packages/schemas ./packages/schemas COPY ./packages/shared ./packages/shared COPY ./packages/queryLanguage ./packages/queryLanguage -RUN yarn workspace @sourcebot/db install -RUN yarn workspace @sourcebot/schemas install -RUN yarn workspace @sourcebot/shared install -RUN yarn workspace @sourcebot/query-language install +RUN --mount=type=cache,id=sourcebot-yarn-cache,target=/app/.yarn/cache \ + yarn workspace @sourcebot/db install +RUN --mount=type=cache,id=sourcebot-yarn-cache,target=/app/.yarn/cache \ + yarn workspace @sourcebot/schemas install +RUN --mount=type=cache,id=sourcebot-yarn-cache,target=/app/.yarn/cache \ + yarn workspace @sourcebot/shared install +RUN --mount=type=cache,id=sourcebot-yarn-cache,target=/app/.yarn/cache \ + yarn workspace @sourcebot/query-language install # ------------------------------------ # ------ Build Web ------ @@ -89,7 +97,8 @@ COPY --from=shared-libs-builder /app/packages/shared ./packages/shared COPY --from=shared-libs-builder /app/packages/queryLanguage ./packages/queryLanguage # Fixes arm64 timeouts -RUN yarn workspace @sourcebot/web install +RUN --mount=type=cache,id=sourcebot-yarn-cache,target=/app/.yarn/cache \ + yarn workspace @sourcebot/web install ENV NEXT_TELEMETRY_DISABLED=1 RUN yarn workspace @sourcebot/web build @@ -126,7 +135,8 @@ COPY --from=shared-libs-builder /app/packages/db ./packages/db COPY --from=shared-libs-builder /app/packages/schemas ./packages/schemas COPY --from=shared-libs-builder /app/packages/shared ./packages/shared COPY --from=shared-libs-builder /app/packages/queryLanguage ./packages/queryLanguage -RUN yarn workspace @sourcebot/backend install +RUN --mount=type=cache,id=sourcebot-yarn-cache,target=/app/.yarn/cache \ + yarn workspace @sourcebot/backend install RUN yarn workspace @sourcebot/backend build # Upload source maps to Sentry if we have the necessary build-time args. From 167661f234df31e2c1c2ca0d4022908f95e16fcd Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 3 Apr 2026 20:47:41 +0000 Subject: [PATCH 2/3] fix(docker): lock shared BuildKit yarn cache mounts Co-authored-by: Michael Sukkarieh --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index d22c1fea9..9c909bae2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,13 +44,13 @@ COPY ./packages/schemas ./packages/schemas COPY ./packages/shared ./packages/shared COPY ./packages/queryLanguage ./packages/queryLanguage -RUN --mount=type=cache,id=sourcebot-yarn-cache,target=/app/.yarn/cache \ +RUN --mount=type=cache,id=sourcebot-yarn-cache,sharing=locked,target=/app/.yarn/cache \ yarn workspace @sourcebot/db install -RUN --mount=type=cache,id=sourcebot-yarn-cache,target=/app/.yarn/cache \ +RUN --mount=type=cache,id=sourcebot-yarn-cache,sharing=locked,target=/app/.yarn/cache \ yarn workspace @sourcebot/schemas install -RUN --mount=type=cache,id=sourcebot-yarn-cache,target=/app/.yarn/cache \ +RUN --mount=type=cache,id=sourcebot-yarn-cache,sharing=locked,target=/app/.yarn/cache \ yarn workspace @sourcebot/shared install -RUN --mount=type=cache,id=sourcebot-yarn-cache,target=/app/.yarn/cache \ +RUN --mount=type=cache,id=sourcebot-yarn-cache,sharing=locked,target=/app/.yarn/cache \ yarn workspace @sourcebot/query-language install # ------------------------------------ @@ -97,7 +97,7 @@ COPY --from=shared-libs-builder /app/packages/shared ./packages/shared COPY --from=shared-libs-builder /app/packages/queryLanguage ./packages/queryLanguage # Fixes arm64 timeouts -RUN --mount=type=cache,id=sourcebot-yarn-cache,target=/app/.yarn/cache \ +RUN --mount=type=cache,id=sourcebot-yarn-cache,sharing=locked,target=/app/.yarn/cache \ yarn workspace @sourcebot/web install ENV NEXT_TELEMETRY_DISABLED=1 @@ -135,7 +135,7 @@ COPY --from=shared-libs-builder /app/packages/db ./packages/db COPY --from=shared-libs-builder /app/packages/schemas ./packages/schemas COPY --from=shared-libs-builder /app/packages/shared ./packages/shared COPY --from=shared-libs-builder /app/packages/queryLanguage ./packages/queryLanguage -RUN --mount=type=cache,id=sourcebot-yarn-cache,target=/app/.yarn/cache \ +RUN --mount=type=cache,id=sourcebot-yarn-cache,sharing=locked,target=/app/.yarn/cache \ yarn workspace @sourcebot/backend install RUN yarn workspace @sourcebot/backend build From 91421b0716c269e023361acf84095a1cb7ee0d3a Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 3 Apr 2026 20:48:39 +0000 Subject: [PATCH 3/3] chore(changelog): document docker build cache improvements Co-authored-by: Michael Sukkarieh --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab3ee05da..9815c1831 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed +- Improved Docker build performance by enabling BuildKit cache mounts for Yarn and Go steps and by reusing Docker layer caches in the PR gate workflow. [#1094](https://github.com/sourcebot-dev/sourcebot/pull/1094) + ## [4.16.7] - 2026-04-03 ### Fixed