@@ -245,6 +245,49 @@ docker build github.com/docker/buildx#d4f088e689b41353d74f1a0bfcd6d7c0b213aed2
245245docker 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
250293By default, BuildKit doesn't keep the ` .git ` directory when using Git contexts.
0 commit comments