Skip to content

Commit 3c0daba

Browse files
PedroGuerraPTgithub-actions[bot]
authored andcommitted
Update docs content from https://github.com/depot/app
1 parent 604df49 commit 3c0daba

File tree

13 files changed

+1516
-173
lines changed

13 files changed

+1516
-173
lines changed

content/api/api-container-builds-tutorial.mdx

Lines changed: 539 additions & 0 deletions
Large diffs are not rendered by default.
File renamed without changes.

content/container-builds/reference/api-overview.mdx renamed to content/api/overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Our API is built with Connect, offering [multiprotocol support](https://connectr
1313

1414
## Authentication
1515

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.
1717

1818
## Security
1919

content/cache/reference/bazel.mdx

Lines changed: 93 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,13 @@ description: Learn how to use Depot remote caching for Bazel builds
1010

1111
## Configuring Bazel to use Depot Cache
1212

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.
1414

1515
### From Depot-managed Actions runners
1616

1717
[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.
1818

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.
3720

3821
### Using Depot Cache with Bazel in `depot/build-push-action`
3922

@@ -74,3 +57,94 @@ RUN --mount=type=secret,id=DEPOT_TOKEN,env=DEPOT_TOKEN \
7457
```
7558

7659
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 \
91+
echo "build --remote_cache=https://cache.depot.dev" >> ~/.bazelrc && \
92+
echo "build --remote_header=authorization=${DEPOT_TOKEN}" >> ~/.bazelrc && \
93+
bazel build
94+
```
95+
96+
Adding `# syntax=docker/dockerfile:1` as the first line of your Dockerfile enables mounting secrets as environment variables.
97+
98+
2. Build with Depot CLI:
99+
100+
```shell
101+
depot build --secret id=DEPOT_TOKEN,env=DEPOT_TOKEN -t your-image:tag .
102+
```
103+
104+
Or with Docker Buildx:
105+
106+
```shell
107+
docker buildx build --secret id=DEPOT_TOKEN,env=DEPOT_TOKEN -t your-image:tag .
108+
```
109+
110+
### Using Depot Cache with Bazel in Bake files
111+
112+
When using Bake files to build Docker images containing Bazel workspaces, you can pass secrets through the `target.secret` attribute:
113+
114+
1. Define the secret in your `docker-bake.hcl` file:
115+
116+
```hcl
117+
target "default" {
118+
context = "."
119+
dockerfile = "Dockerfile"
120+
tags = ["your-image:tag"]
121+
secret = [
122+
{
123+
type = "env"
124+
id = "DEPOT_TOKEN"
125+
}
126+
]
127+
}
128+
```
129+
130+
2. Update your Dockerfile to mount the secret and configure Bazel:
131+
132+
```dockerfile
133+
# syntax=docker/dockerfile:1
134+
135+
# ... other Dockerfile instructions
136+
137+
# Create .bazelrc with cache configuration
138+
RUN --mount=type=secret,id=DEPOT_TOKEN,env=DEPOT_TOKEN \
139+
echo "build --remote_cache=https://cache.depot.dev" >> ~/.bazelrc && \
140+
echo "build --remote_header=authorization=${DEPOT_TOKEN}" >> ~/.bazelrc && \
141+
bazel build
142+
```
143+
144+
Adding `# syntax=docker/dockerfile:1` as the first line of your Dockerfile enables mounting secrets as environment variables.
145+
146+
3. Run the build with `depot bake`:
147+
148+
```shell
149+
DEPOT_TOKEN=your_token depot bake
150+
```

content/cache/reference/gocache.mdx

Lines changed: 101 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,58 @@ description: Learn how to use Depot remote caching for Go
66

77
## Configuring Go to use Depot Cache
88

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.
1010

1111
### From Depot-managed Actions runners
1212

1313
[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.
1414

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.
1616

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
1861

1962
To manually configure Go to use Depot Cache, set the `GOCACHEPROG` in your environment:
2063

@@ -42,33 +85,64 @@ To set verbose output, add the --verbose option:
4285
export GOCACHEPROG='depot gocache --verbose'
4386
```
4487

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.
4689

47-
### Using Depot Cache with Go in `depot/build-push-action`
90+
### Using Depot Cache with Go in Depot CLI
4891

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:
5093

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:
5295

53-
Follow these steps to securely pass your Go cache credentials into your Docker build:
96+
```dockerfile
97+
# syntax=docker/dockerfile:1
5498

55-
1. Store the Depot token in a GitHub Secret named `DEPOT_TOKEN`.
99+
# ... other Dockerfile instructions
56100

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
58103

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 ./
69109
```
70110

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.
112+
113+
2. Build with Depot CLI:
114+
115+
```shell
116+
depot build --secret id=DEPOT_TOKEN,env=DEPOT_TOKEN -t your-image:tag .
117+
```
118+
119+
Or with Docker Buildx:
120+
121+
```shell
122+
docker buildx build --secret id=DEPOT_TOKEN,env=DEPOT_TOKEN -t your-image:tag .
123+
```
124+
125+
### Using Depot Cache with Go in Bake files
126+
127+
When using Bake files to build Docker images containing Go projects, you can pass secrets through the `target.secret` attribute:
128+
129+
1. Define the secret in your `docker-bake.hcl` file:
130+
131+
```hcl
132+
target "default" {
133+
context = "."
134+
dockerfile = "Dockerfile"
135+
tags = ["your-image:tag"]
136+
secret = [
137+
{
138+
type = "env"
139+
id = "DEPOT_TOKEN"
140+
}
141+
]
142+
}
143+
```
144+
145+
2. Update your Dockerfile to install the Depot CLI and configure Go cache:
72146

73147
```dockerfile
74148
# syntax=docker/dockerfile:1
@@ -86,3 +160,9 @@ RUN --mount=type=secret,id=DEPOT_TOKEN,env=DEPOT_TOKEN \
86160
```
87161

88162
Adding `# syntax=docker/dockerfile:1` as the first line of your Dockerfile enables mounting secrets as environment variables.
163+
164+
3. Run the build with `depot bake`:
165+
166+
```shell
167+
DEPOT_TOKEN=your_token depot bake
168+
```

0 commit comments

Comments
 (0)