Skip to content

Commit 07c6c5e

Browse files
committed
build: update git url queries behavior
Signed-off-by: CrazyMax <[email protected]>
1 parent 2726a40 commit 07c6c5e

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

content/manuals/build/concepts/context.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,9 @@ docker build github.com/docker/buildx#d4f088e
247247

248248
### URL queries
249249

250-
Starting with Buildx v0.28 and BuildKit v0.24, URL queries are also supported.
251-
URL queries are more structured and recommended over [URL fragments](#url-fragments).
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):
252252

253-
For example,
254253
```console
255254
$ docker buildx build 'https://github.com/user/myrepo.git?branch=container&subdir=docker'
256255
```
@@ -266,13 +265,29 @@ $ docker buildx build 'https://github.com/user/myrepo.git?branch=container&subdi
266265
| `myrepo.git?tag=mytag&subdir=myfolder` | `refs/tags/mytag` | `/myfolder` |
267266
| `myrepo.git?branch=mybranch&subdir=myfolder` | `refs/heads/mybranch` | `/myfolder` |
268267

269-
A commit hash can be specified as a `commit` or `checksum` query, along with `tag`, `branch`, or `ref`.
270-
A hash does not need to be a full hash.
268+
A commit hash can be specified as a `checksum` (alias `commit`) query, along
269+
`tag`, `branch`, or `ref` queries to verify that the reference resolves to the
270+
expected commit:
271271

272-
```bash
273-
docker buildx build 'https://github.com/moby/buildkit.git?tag=v0.21.1&checksum=66735c67'
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
274284
```
275285

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+
276291
#### Keep `.git` directory
277292

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

0 commit comments

Comments
 (0)