Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/pr-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 19 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1
# syntax=docker/dockerfile:1.7
# ------ Global scope variables ------

# Set of global build arguments.
Expand All @@ -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 ------
Expand All @@ -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,sharing=locked,target=/app/.yarn/cache \
yarn workspace @sourcebot/db install
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,sharing=locked,target=/app/.yarn/cache \
yarn workspace @sourcebot/shared install
RUN --mount=type=cache,id=sourcebot-yarn-cache,sharing=locked,target=/app/.yarn/cache \
yarn workspace @sourcebot/query-language install
# ------------------------------------

# ------ Build Web ------
Expand Down Expand Up @@ -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,sharing=locked,target=/app/.yarn/cache \
yarn workspace @sourcebot/web install

ENV NEXT_TELEMETRY_DISABLED=1
RUN yarn workspace @sourcebot/web build
Expand Down Expand Up @@ -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,sharing=locked,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.
Expand Down
Loading