You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/api/overview.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ Our API is built with Connect, offering [multiprotocol support](https://connectr
13
13
14
14
## Authentication
15
15
16
-
Authentication to the API is handled via an `Authorization` header with the value being an Organization Token that you generate inside of your Organization Settings. See the [Authentication docs](/docs/container-builds/reference/api-authentication) for more details.
16
+
Authentication to the API is handled via an `Authorization` header with the value being an Organization Token that you generate inside of your Organization Settings. See the [Authentication docs](/docs/api/authentication) for more details.
Copy file name to clipboardExpand all lines: content/cache/reference/bazel.mdx
+93-19Lines changed: 93 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,30 +10,13 @@ description: Learn how to use Depot remote caching for Bazel builds
10
10
11
11
## Configuring Bazel to use Depot Cache
12
12
13
-
Depot Cache can be used with Bazel from Depot's managed GitHub Actions runners, from your local machine, or from any CI/CD system.
13
+
Depot Cache can be used with Bazel from Depot's managed GitHub Actions runners, from your local machine, from any CI/CD system, or within containerized builds using Dockerfiles or Bake files.
14
14
15
15
### From Depot-managed Actions runners
16
16
17
17
[Depot GitHub Actions runners](/docs/github-actions/overview) are pre-configured to use Depot Cache with Bazel - each runner is launched with a `$HOME/.bazelrc` file that is pre-populated with the connection details for Depot Cache.
18
18
19
-
If this automatic configuration is incompatible with your specific setup, you can disable automatic configuration in your organization settings page and manually configure Bazel to use Depot Cache as described below.
20
-
21
-
### From your local machine or any CI/CD system
22
-
23
-
To manually configure Bazel to use Depot Cache, you will need to set two build flags in your `.bazelrc` file. Configure Bazel to use the Depot Cache service endpoint and set API token as the `authorization` header:
24
-
25
-
```bash
26
-
build --remote_cache=https://cache.depot.dev
27
-
build --remote_header=authorization=DEPOT_TOKEN
28
-
```
29
-
30
-
If you are a member of multiple organizations, and you are authenticating with a user token, you must additionally specify which organization to use for cache storage with the `x-depot-org` header:
31
-
32
-
```bash
33
-
build --remote_header=x-depot-org=DEPOT_ORG_ID
34
-
```
35
-
36
-
Once Bazel is configured to use Depot Cache, you can then run your builds as you normally would. Bazel will automatically communicate with Depot Cache to fetch and reuse any stored build artifacts from your previous builds.
19
+
If you don't want Depot to override the `$HOME/.bazelrc` file on each runner, disable **Allow Actions jobs to automatically connect to Depot Cache** in your organization settings page. You can manually configure Bazel to use Depot Cache as described in the "Using Depot Cache from your local machine or any CI/CD system" section.
37
20
38
21
### Using Depot Cache with Bazel in `depot/build-push-action`
39
22
@@ -74,3 +57,94 @@ RUN --mount=type=secret,id=DEPOT_TOKEN,env=DEPOT_TOKEN \
74
57
```
75
58
76
59
Adding `# syntax=docker/dockerfile:1` as the first line of your Dockerfile enables mounting secrets as environment variables.
60
+
61
+
### Using Depot Cache from your local machine or any CI/CD system
62
+
63
+
To manually configure Bazel to use Depot Cache, you will need to set two build flags in your `.bazelrc` file. Configure Bazel to use the Depot Cache service endpoint and set API token as the `authorization` header:
64
+
65
+
```bash
66
+
build --remote_cache=https://cache.depot.dev
67
+
build --remote_header=authorization=DEPOT_TOKEN
68
+
```
69
+
70
+
If you are a member of multiple organizations, and you are authenticating with a user token, you must additionally specify which organization to use for cache storage with the `x-depot-org` header:
71
+
72
+
```bash
73
+
build --remote_header=x-depot-org=DEPOT_ORG_ID
74
+
```
75
+
76
+
After Bazel is configured to use Depot Cache, you can then run your builds as you normally would. Bazel will automatically communicate with Depot Cache to fetch and reuse any stored build artifacts from your previous builds.
77
+
78
+
### Using Depot Cache with Bazel in Depot CLI
79
+
80
+
When building directly with Depot CLI, follow these steps:
81
+
82
+
1. Update your Dockerfile to mount the secret and configure Bazel:
83
+
84
+
```dockerfile
85
+
# syntax=docker/dockerfile:1
86
+
87
+
# ... other Dockerfile instructions
88
+
89
+
# Create .bazelrc with cache configuration
90
+
RUN --mount=type=secret,id=DEPOT_TOKEN,env=DEPOT_TOKEN \
@@ -6,15 +6,58 @@ description: Learn how to use Depot remote caching for Go
6
6
7
7
## Configuring Go to use Depot Cache
8
8
9
-
Depot Cache can be used with Go from Depot's managed GitHub Actions runners, from your local machine, or from any CI/CD system.
9
+
Depot Cache can be used with Go from Depot's managed GitHub Actions runners, from your local machine, from any CI/CD system, or within containerized builds using Dockerfiles or Bake files.
10
10
11
11
### From Depot-managed Actions runners
12
12
13
13
[Depot GitHub Actions runners](/docs/github-actions/overview) are pre-configured to use Depot Cache with Go - each runner is launched with the `GOCACHEPROG` environment variable pre-populated with the connection details for Depot Cache.
14
14
15
-
If this automatic configuration is incompatible with your specific setup, you can disable automatic configuration in your organization settings page and manually configure `GOCACHEPROG` to use Depot Cache as described below.
15
+
If you don't want Depot to set up the `GOCACHEPROG` environment variable on each runner, disable **Allow Actions jobs to automatically connect to Depot Cache**in your organization settings page. You can manually configure `GOCACHEPROG` to use Depot Cache as described in the "Using Depot Cache from your local machine or any CI/CD system" section.
16
16
17
-
### From your local machine or any CI/CD system
17
+
### Using Depot Cache with Go in `depot/build-push-action`
18
+
19
+
When using `depot/build-push-action` to build Docker images that contain Go projects, your build needs access to Go's remote cache credentials to benefit from caching.
20
+
21
+
These credentials are not automatically available inside your Docker build environment. Unlike builds running directly on Depot-managed GitHub Actions runners (which have automatic access to Depot Cache environment variables), containerized builds execute in isolated VMs that require explicit configuration.
22
+
23
+
Follow these steps to securely pass your Go cache credentials into your Docker build:
24
+
25
+
1. Store the Depot token in a GitHub Secret named `DEPOT_TOKEN`.
26
+
27
+
2. Configure your GitHub Action to pass secrets to the container build:
28
+
29
+
```yaml
30
+
- name: Build and push
31
+
uses: depot/build-push-action@v1
32
+
with:
33
+
context: .
34
+
file: ./Dockerfile
35
+
push: true
36
+
tags: your-image:tag
37
+
secrets: |
38
+
"DEPOT_TOKEN=${{ secrets.DEPOT_TOKEN }}"
39
+
```
40
+
41
+
3. Update your Dockerfile to install the Depot CLI and configure Go cache:
42
+
43
+
```dockerfile
44
+
# syntax=docker/dockerfile:1
45
+
46
+
# ... other Dockerfile instructions
47
+
48
+
# Install Depot CLI
49
+
RUN curl -L https://depot.dev/install-cli.sh | sh
50
+
51
+
# Mount secret and set GOCACHEPROG
52
+
RUN --mount=type=secret,id=DEPOT_TOKEN,env=DEPOT_TOKEN \
53
+
PATH="/root/.depot/bin:$PATH" \
54
+
GOCACHEPROG="depot gocache" \
55
+
go build -v ./
56
+
```
57
+
58
+
Adding `# syntax=docker/dockerfile:1` as the first line of your Dockerfile enables mounting secrets as environment variables.
59
+
60
+
### Using Depot Cache from your local machine or any CI/CD system
18
61
19
62
To manually configure Go to use Depot Cache, set the `GOCACHEPROG` in your environment:
20
63
@@ -42,33 +85,64 @@ To set verbose output, add the --verbose option:
42
85
export GOCACHEPROG='depot gocache --verbose'
43
86
```
44
87
45
-
Once Go is configured to use Depot Cache, you can then run your builds as you normally would. Go will automatically communicate with `GOCACHEPROG` to fetch from Depot Cache and reuse any stored build artifacts from your previous builds.
88
+
After Go is configured to use Depot Cache, you can then run your builds as you normally would. Go will automatically communicate with `GOCACHEPROG` to fetch from Depot Cache and reuse any stored build artifacts from your previous builds.
46
89
47
-
### Using Depot Cache with Go in `depot/build-push-action`
90
+
### Using Depot Cache with Go in Depot CLI
48
91
49
-
When using `depot/build-push-action` to build Docker images that contain Go projects, your build needs access to Go's remote cache credentials to benefit from caching.
92
+
When building directly with Depot CLI, follow these steps:
50
93
51
-
These credentials are not automatically available inside your Docker build environment. Unlike builds running directly on Depot-managed GitHub Actions runners (which have automatic access to Depot Cache environment variables), containerized builds execute in isolated VMs that require explicit configuration.
94
+
1. Update your Dockerfile to install the Depot CLI and configure Go cache:
52
95
53
-
Follow these steps to securely pass your Go cache credentials into your Docker build:
96
+
```dockerfile
97
+
# syntax=docker/dockerfile:1
54
98
55
-
1. Store the Depot token in a GitHub Secret named `DEPOT_TOKEN`.
99
+
# ... other Dockerfile instructions
56
100
57
-
2. Configure your GitHub Action to pass secrets to the container build:
101
+
# Install Depot CLI
102
+
RUN curl -L https://depot.dev/install-cli.sh | sh
58
103
59
-
```yaml
60
-
- name: Build and push
61
-
uses: depot/build-push-action@v1
62
-
with:
63
-
context: .
64
-
file: ./Dockerfile
65
-
push: true
66
-
tags: your-image:tag
67
-
secrets: |
68
-
"DEPOT_TOKEN=${{ secrets.DEPOT_TOKEN }}"
104
+
# Mount secret and set GOCACHEPROG
105
+
RUN --mount=type=secret,id=DEPOT_TOKEN,env=DEPOT_TOKEN \
106
+
PATH="/root/.depot/bin:$PATH" \
107
+
GOCACHEPROG="depot gocache" \
108
+
go build -v ./
69
109
```
70
110
71
-
3. Update your Dockerfile to install the Depot CLI and configure Go cache:
111
+
Adding `# syntax=docker/dockerfile:1` as the first line of your Dockerfile enables mounting secrets as environment variables.
0 commit comments