diff options
Diffstat (limited to 'docker/api/build.py')
-rw-r--r-- | docker/api/build.py | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/docker/api/build.py b/docker/api/build.py index d69985e..419255f 100644 --- a/docker/api/build.py +++ b/docker/api/build.py @@ -264,6 +264,23 @@ class BuildApiMixin(object): return self._stream_helper(response, decode=decode) + @utils.minimum_version('1.31') + def prune_builds(self): + """ + Delete the builder cache + + Returns: + (dict): A dictionary containing information about the operation's + result. The ``SpaceReclaimed`` key indicates the amount of + bytes of disk space reclaimed. + + Raises: + :py:class:`docker.errors.APIError` + If the server returns an error. + """ + url = self._url("/build/prune") + return self._result(self._post(url), True) + def _set_auth_headers(self, headers): log.debug('Looking for auth config') @@ -285,7 +302,8 @@ class BuildApiMixin(object): # credentials/native_store.go#L68-L83 for registry in self._auth_configs.get('auths', {}).keys(): auth_data[registry] = auth.resolve_authconfig( - self._auth_configs, registry + self._auth_configs, registry, + credstore_env=self.credstore_env, ) else: auth_data = self._auth_configs.get('auths', {}).copy() @@ -316,10 +334,17 @@ def process_dockerfile(dockerfile, path): if (os.path.splitdrive(path)[0] != os.path.splitdrive(abs_dockerfile)[0] or os.path.relpath(abs_dockerfile, path).startswith('..')): + # Dockerfile not in context - read data to insert into tar later with open(abs_dockerfile, 'r') as df: return ( '.dockerfile.{0:x}'.format(random.getrandbits(160)), df.read() ) - else: - return (dockerfile, None) + + # Dockerfile is inside the context - return path relative to context root + if dockerfile == abs_dockerfile: + # Only calculate relpath if necessary to avoid errors + # on Windows client -> Linux Docker + # see https://github.com/docker/compose/issues/5969 + dockerfile = os.path.relpath(abs_dockerfile, path) + return (dockerfile, None) |