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/manuals/build-cloud/ci.md
+51-50Lines changed: 51 additions & 50 deletions
Original file line number
Diff line number
Diff line change
@@ -36,42 +36,42 @@ See [Loading build results](./usage/#loading-build-results) for details.
36
36
37
37
To enable your CI/CD system to build and push images using Docker Build Cloud, provide both an access token and a username. The type of token and the username you use depend on your account type and permissions.
38
38
39
-
- If you are an organization administrator or have permission to create [organization access tokens (OAT)](../security/for-admins/access-tokens.md), use an OAT and set `DOCKER_USER` to your Docker Hub organization name.
40
-
- If you do not have permission to create OATs or are using a personal account, use a [personal access token (PAT)](/security/for-developers/access-tokens/) and set `DOCKER_USER` to your Docker Hub username.
39
+
- If you are an organization administrator or have permission to create [organization access tokens (OAT)](../security/for-admins/access-tokens.md), use an OAT and set `DOCKER_ACCOUNT` to your Docker Hub organization name.
40
+
- If you do not have permission to create OATs or are using a personal account, use a [personal access token (PAT)](/security/for-developers/access-tokens/) and set `DOCKER_ACCOUNT` to your Docker Hub username.
41
41
42
42
### Creating access tokens
43
43
44
44
#### For organization accounts
45
45
46
46
If you are an organization administrator:
47
47
48
-
1. Create an [organization access token (OAT)](../security/for-admins/access-tokens.md):
49
-
- The token must have these permissions:
50
-
-**cloud-connect** scope
51
-
-**Read public repositories** permission
52
-
-**Repository access** with **Image push** permission for the target repository:
53
-
- Expand the **Repository** drop-down.
54
-
- Select **Add repository** and choose your target repository.
55
-
- Set the **Image push** permission for the repository.
48
+
- Create an [organization access token (OAT)](../security/for-admins/access-tokens.md). The token must have these permissions:
49
+
1.**cloud-connect** scope
50
+
2.**Read public repositories** permission
51
+
3.**Repository access** with **Image push** permission for the target repository:
52
+
- Expand the **Repository** drop-down.
53
+
- Select **Add repository** and choose your target repository.
54
+
- Set the **Image push** permission for the repository.
56
55
57
56
If you are not an organization administrator:
58
57
59
58
- Ask your organization administrator for an access token with the permissions listed above, or use a personal access token.
60
59
61
60
#### For personal accounts
62
61
63
-
1. Create a [personal access token (PAT)](/security/for-developers/access-tokens/):
64
-
- Create a new token with**Read & write** access.
65
-
- Note: Building with Docker Build Cloud only requires read access, but you need write access to push images to a Docker Hub repository.
62
+
- Create a [personal access token (PAT)](/security/for-developers/access-tokens/) with the following permissions:
63
+
1.**Read & write** access.
64
+
- Note: Building with Docker Build Cloud only requires read access, but you need write access to push images to a Docker Hub repository.
66
65
67
66
68
67
## CI platform examples
69
68
70
69
> [!NOTE]
71
70
>
72
-
> In your CI/CD configuration, set the following variables:
73
-
> -`DOCKER_PAT` — your access token (PAT or OAT)
74
-
> -`DOCKER_USER` — your Docker Hub username (for PAT) or organization name (for OAT)
71
+
> In your CI/CD configuration, set the following variables/secrets:
72
+
> -`DOCKER_ACCESS_TOKEN` — your access token (PAT or OAT). Use a secret to store the token.
73
+
> -`DOCKER_ACCOUNT` — your Docker Hub organization name (for OAT) or username (for PAT)
74
+
> -`CLOUD_BUILDER_NAME` — the name of the cloud builder you created in the [Docker Build Cloud Dashboard](https://app.docker.com/build/)
75
75
>
76
76
> This ensures your builds authenticate correctly with Docker Build Cloud.
77
77
@@ -92,20 +92,20 @@ jobs:
92
92
- name: Login to Docker Hub
93
93
uses: docker/login-action@v3
94
94
with:
95
-
username: ${{ vars.DOCKER_USER }}
96
-
password: ${{ secrets.DOCKER_PAT }}
95
+
username: ${{ vars.DOCKER_ACCOUNT }}
96
+
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
97
97
98
98
- name: Set up Docker Buildx
99
99
uses: docker/setup-buildx-action@v3
100
100
with:
101
101
driver: cloud
102
-
endpoint: "<ORG>/default"
102
+
endpoint: "${{ vars.DOCKER_ACCOUNT }}/${{ vars.CLOUD_BUILDER_NAME }}"# for example, "acme/default"
103
103
install: true
104
104
105
105
- name: Build and push
106
106
uses: docker/build-push-action@v6
107
107
with:
108
-
tags: "<IMAGE>"
108
+
tags: "<IMAGE>"# for example, "acme/my-image:latest"
109
109
# For pull requests, export results to the build cache.
DOCKER_ACCOUNT: <DOCKER_ACCOUNT> # your Docker Hub organization name (or username when using a personal account)
136
+
CLOUD_BUILDER_NAME: <CLOUD_BUILDER_NAME> # the name of the cloud builder you created in the [Docker Build Cloud Dashboard](https://app.docker.com/build/)
136
137
137
138
# Build multi-platform image and push to a registry
Create a `pipeline.yml` that uses the `docker-login` plugin:
239
240
240
241
```yaml
241
242
env:
242
-
DOCKER_ORG: <ORG>
243
+
DOCKER_ACCOUNT: <DOCKER_ACCOUNT> # your Docker Hub organization name (or username when using a personal account)
244
+
CLOUD_BUILDER_NAME: <CLOUD_BUILDER_NAME> # the name of the cloud builder you created in the [Docker Build Cloud Dashboard](https://app.docker.com/build/)
243
245
IMAGE_NAME: <IMAGE>
244
246
245
247
steps:
246
248
- command: ./build.sh
247
249
key: build-push
248
250
plugins:
249
251
- docker-login#v2.1.0:
250
-
username: <DOCKER_USER>
251
-
password-env: DOCKER_PAT # the variable name in the environment hook
252
+
username: DOCKER_ACCOUNT
253
+
password-env: DOCKER_ACCESS_TOKEN # the variable name in the environment hook
# Login to Docker Hub. For security reasons $DOCKER_PAT should be a Personal Access Token. See https://docs.docker.com/build-cloud/ci/#creating-access-tokens
# Login to Docker Hub. For security reasons $DOCKER_PAT should be a Personal Access Token. See https://docs.docker.com/build-cloud/ci/#creating-access-tokens
Replace `ORG` with the Docker Hub namespace of your Docker organization.
54
+
Replace `<ORG>` with the Docker Hub namespace of your Docker organization (or your username if you are using a personal account), and `<BUILDER_NAME>` with the name you chose when creating the builder in the dashboard.
55
+
56
+
This creates a local instance of the cloud builder named `cloud-ORG-BUILDER_NAME`.
57
+
58
+
> [!NOTE]
59
+
> Example:
60
+
>
61
+
> If your organization is `acme` and you named your builder `default`, use:
0 commit comments