Skip to content

Modern Docker Management, Designed for Everyone

ci/cd: use go cache from depot

Kyle Mendelle83c717a96cc
diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml
index 88c04bee1..f118dc348 100644
--- a/.github/workflows/e2e-tests.yml
+++ b/.github/workflows/e2e-tests.yml
@@ -50,6 +50,8 @@ jobs:
file: docker/Dockerfile
build-args: BUILD_TAGS=playwright
save: true
+ secrets: |
+ "DEPOT_TOKEN=${{ secrets.DEPOT_TOKEN }}"
- name: Export build ID for tests
run: echo "BUILD_ID=${{ steps.build.outputs.build-id }}" >> $GITHUB_ENV
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 87668597a..0b5a8093e 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -101,6 +101,8 @@ jobs:
build-args: |
VERSION=${{ github.ref_name }}
REVISION=${{ github.sha }}
+ secrets: |
+ "DEPOT_TOKEN=${{ secrets.DEPOT_TOKEN }}"
outputs:
digest: ${{ steps.build.outputs.digest }}
@@ -144,6 +146,8 @@ jobs:
build-args: |
VERSION=${{ github.ref_name }}
REVISION=${{ github.sha }}
+ secrets: |
+ "DEPOT_TOKEN=${{ secrets.DEPOT_TOKEN }}"
outputs:
digest: ${{ steps.build.outputs.digest }}
diff --git a/docker/Dockerfile b/docker/Dockerfile
index c7c8388af..ba3b0b4b2 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,3 +1,5 @@
+# syntax=docker/dockerfile:1
+
# Tags passed to "go build"
ARG BUILD_TAGS=""
@@ -18,14 +20,21 @@ FROM golang:1.25-alpine AS backend-builder
ARG BUILD_TAGS
WORKDIR /build
RUN apk add --no-cache ca-certificates curl git tzdata
+
+# Install Depot CLI
+RUN curl -L https://depot.dev/install-cli.sh | sh
+
COPY ./.version ./VERSION
COPY ./backend/go.mod ./backend/go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod go mod download
COPY ./backend ./
COPY --from=frontend-builder /build/frontend/dist ./frontend/dist
-RUN --mount=type=cache,target=/root/.cache/go-build \
+RUN --mount=type=secret,id=DEPOT_TOKEN,env=DEPOT_TOKEN \
+ --mount=type=cache,target=/root/.cache/go-build \
VERSION=$(cat VERSION | tr -d '[:space:]') && \
REVISION=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") && \
+ PATH="/root/.depot/bin:$PATH" \
+ GOCACHEPROG="depot gocache" \
CGO_ENABLED=0 GOOS=linux \
go build \
-tags "${BUILD_TAGS}" \
diff --git a/docker/Dockerfile-agent b/docker/Dockerfile-agent
index 6a8168747..c83a9d8a9 100644
--- a/docker/Dockerfile-agent
+++ b/docker/Dockerfile-agent
@@ -1,3 +1,5 @@
+# syntax=docker/dockerfile:1
+
# Build agent binary
ARG VERSION="dev"
ARG REVISION="unknown"
@@ -8,6 +10,9 @@ WORKDIR /build
RUN apk add --no-cache git ca-certificates tzdata curl
+# Install Depot CLI
+RUN curl -L https://depot.dev/install-cli.sh | sh
+
COPY ./.version ./VERSION
COPY ./backend/go.mod ./backend/go.sum ./
RUN go mod download
@@ -15,8 +20,11 @@ RUN go mod download
COPY ./backend ./backend
WORKDIR /build/backend
-RUN VERSION=$(cat ../VERSION | tr -d '[:space:]') && \
+RUN --mount=type=secret,id=DEPOT_TOKEN,env=DEPOT_TOKEN \
+ VERSION=$(cat ../VERSION | tr -d '[:space:]') && \
REVISION=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") && \
+ PATH="/root/.depot/bin:$PATH" \
+ GOCACHEPROG="depot gocache" \
CGO_ENABLED=0 GOOS=linux \
go build \
-tags "${BUILD_TAGS}" \