Skip to content

Commit 741679e

Browse files
AkihiroSudacrazy-maxaevesdocker
authored
build: document URL queries (#23322)
<!--Delete sections as needed --> ## Description <!-- Tell us what you did and why --> BuildKit v0.24 introduces URL like `https://github.com/example/example.git?tag=v0.0.1&checksum=deadbeef` ## Related issues or tickets <!-- Related issues, pull requests, or Jira tickets --> - moby/buildkit#6172 - moby/buildkit#6173 ## Reviews <!-- Notes for reviewers here --> <!-- List applicable reviews (optionally @tag reviewers) --> - [X] Technical review - [X] Editorial review - [ ] Product review --------- Signed-off-by: Akihiro Suda <[email protected]> Signed-off-by: CrazyMax <[email protected]> Co-authored-by: CrazyMax <[email protected]> Co-authored-by: Allie Sadler <[email protected]>
1 parent 91bf53e commit 741679e

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

content/manuals/build/concepts/context.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,49 @@ docker build github.com/docker/buildx#d4f088e689b41353d74f1a0bfcd6d7c0b213aed2
245245
docker build github.com/docker/buildx#d4f088e
246246
```
247247

248+
#### URL queries
249+
250+
Starting with Buildx v0.28, BuildKit v0.24 and Dockerfile v1.18, URL queries are
251+
also supported. URL queries are more structured and recommended over [URL fragments](#url-fragments):
252+
253+
```console
254+
$ docker buildx build 'https://github.com/user/myrepo.git?branch=container&subdir=docker'
255+
```
256+
257+
| Build syntax suffix | Commit used | Build context used |
258+
| -------------------------------------------- | ----------------------------- | ------------------ |
259+
| `myrepo.git` | `refs/heads/<default branch>` | `/` |
260+
| `myrepo.git?tag=mytag` | `refs/tags/mytag` | `/` |
261+
| `myrepo.git?branch=mybranch` | `refs/heads/mybranch` | `/` |
262+
| `myrepo.git?ref=pull/42/head` | `refs/pull/42/head` | `/` |
263+
| `myrepo.git?subdir=myfolder` | `refs/heads/<default branch>` | `/myfolder` |
264+
| `myrepo.git?branch=master&subdir=myfolder` | `refs/heads/master` | `/myfolder` |
265+
| `myrepo.git?tag=mytag&subdir=myfolder` | `refs/tags/mytag` | `/myfolder` |
266+
| `myrepo.git?branch=mybranch&subdir=myfolder` | `refs/heads/mybranch` | `/myfolder` |
267+
268+
A commit hash can be specified as a `checksum` (alias `commit`) query, along with
269+
`tag`, `branch`, or `ref` queries to verify that the reference resolves to the
270+
expected commit:
271+
272+
```console
273+
$ docker buildx build 'https://github.com/moby/buildkit.git?tag=v0.21.1&checksum=66735c67'
274+
```
275+
276+
If it doesn't match, the build fails:
277+
278+
```console
279+
$ docker buildx build 'https://github.com/user/myrepo.git?tag=v0.1.0&commit=deadbeef'
280+
...
281+
#3 [internal] load git source https://github.com/user/myrepo.git?tag=v0.1.0-rc1&commit=deadbeef
282+
#3 0.484 bb41e835b6c3523c7c45b248cf4b45e7f862bc42 refs/tags/v0.1.0
283+
#3 ERROR: expected checksum to match deadbeef, got bb41e835b6c3523c7c45b248cf4b45e7f862bc42
284+
```
285+
286+
> [!NOTE]
287+
>
288+
> Short commit hash is supported with `checksum` (alias `commit`) query but for
289+
> `ref`, only the full hash of the commit is supported.
290+
248291
#### Keep `.git` directory
249292

250293
By default, BuildKit doesn't keep the `.git` directory when using Git contexts.

0 commit comments

Comments
 (0)