mirror of https://github.com/docker/docker-py.git
Merge 0a9326348b
into 6e6a273573
This commit is contained in:
commit
1066096195
|
@ -16,7 +16,7 @@ class BuildApiMixin:
|
||||||
decode=False, buildargs=None, gzip=False, shmsize=None,
|
decode=False, buildargs=None, gzip=False, shmsize=None,
|
||||||
labels=None, cache_from=None, target=None, network_mode=None,
|
labels=None, cache_from=None, target=None, network_mode=None,
|
||||||
squash=None, extra_hosts=None, platform=None, isolation=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``
|
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
|
||||||
needs to be set. ``path`` can be a local path (to a directory
|
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]]``
|
platform (str): Platform in the format ``os[/arch[/variant]]``
|
||||||
isolation (str): Isolation technology used during build.
|
isolation (str): Isolation technology used during build.
|
||||||
Default: `None`.
|
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
|
use_config_proxy (bool): If ``True``, and if the docker client
|
||||||
configuration file (``~/.docker/config.json`` by default)
|
configuration file (``~/.docker/config.json`` by default)
|
||||||
contains a proxy configuration, the corresponding environment
|
contains a proxy configuration, the corresponding environment
|
||||||
|
@ -253,6 +257,13 @@ class BuildApiMixin:
|
||||||
)
|
)
|
||||||
params['isolation'] = isolation
|
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:
|
if context is not None:
|
||||||
headers = {'Content-Type': 'application/tar'}
|
headers = {'Content-Type': 'application/tar'}
|
||||||
if encoding:
|
if encoding:
|
||||||
|
|
|
@ -201,6 +201,27 @@ class BuildTest(BaseAPIIntegrationTest):
|
||||||
for _chunk in stream:
|
for _chunk in stream:
|
||||||
pass
|
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')
|
@requires_api_version('1.23')
|
||||||
def test_build_labels(self):
|
def test_build_labels(self):
|
||||||
script = io.BytesIO('\n'.join([
|
script = io.BytesIO('\n'.join([
|
||||||
|
|
Loading…
Reference in New Issue