This commit is contained in:
Felipe Santos 2025-06-30 01:41:16 -03:00 committed by GitHub
commit 1066096195
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 1 deletions

View File

@ -16,7 +16,7 @@ class BuildApiMixin:
decode=False, buildargs=None, gzip=False, shmsize=None,
labels=None, cache_from=None, target=None, network_mode=None,
squash=None, extra_hosts=None, platform=None, isolation=None,
use_config_proxy=True):
version=None, use_config_proxy=True):
"""
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
needs to be set. ``path`` can be a local path (to a directory
@ -101,6 +101,10 @@ class BuildApiMixin:
platform (str): Platform in the format ``os[/arch[/variant]]``
isolation (str): Isolation technology used during build.
Default: `None`.
version (str): Version of the builder backend to use.
- `1` is the first generation classic (deprecated) builder in the Docker daemon (default)
- `2` is [BuildKit](https://github.com/moby/buildkit) over the REST API endpoint provided by the Docker daemon. This mode doesn't use the BuildKit gRPC API, and lacks support for advanced features such as secret mounts.
Default: `None`.
use_config_proxy (bool): If ``True``, and if the docker client
configuration file (``~/.docker/config.json`` by default)
contains a proxy configuration, the corresponding environment
@ -253,6 +257,13 @@ class BuildApiMixin:
)
params['isolation'] = isolation
if version is not None:
if utils.version_lt(self._version, '1.38'):
raise errors.InvalidVersion(
'version was only introduced in API version 1.38'
)
params['version'] = version
if context is not None:
headers = {'Content-Type': 'application/tar'}
if encoding:

View File

@ -201,6 +201,27 @@ class BuildTest(BaseAPIIntegrationTest):
for _chunk in stream:
pass
@requires_api_version('1.38')
def test_build_buildkit_heredoc(self):
script = io.BytesIO('\n'.join([
'FROM scratch',
'COPY <<EOF greeting.txt',
'hello world',
'EOF'
]).encode('ascii'))
self.tmp_imgs.append('buildkit-heredoc')
stream = self.client.build(
fileobj=script, tag='buildkit-heredoc',
version='2'
)
for _chunk in stream:
pass
assert self.client.inspect_image('buildkit-heredoc')
@requires_api_version('1.23')
def test_build_labels(self):
script = io.BytesIO('\n'.join([