mirror of https://github.com/docker/docker-py.git
Resolves #497 - add support for dockerfile
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
d39da11679
commit
0713488fac
|
|
@ -275,7 +275,7 @@ class Client(requests.Session):
|
||||||
def build(self, path=None, tag=None, quiet=False, fileobj=None,
|
def build(self, path=None, tag=None, quiet=False, fileobj=None,
|
||||||
nocache=False, rm=False, stream=False, timeout=None,
|
nocache=False, rm=False, stream=False, timeout=None,
|
||||||
custom_context=False, encoding=None, pull=True,
|
custom_context=False, encoding=None, pull=True,
|
||||||
forcerm=False):
|
forcerm=False, dockerfile=None):
|
||||||
remote = context = headers = None
|
remote = context = headers = None
|
||||||
if path is None and fileobj is None:
|
if path is None and fileobj is None:
|
||||||
raise TypeError("Either path or fileobj needs to be provided.")
|
raise TypeError("Either path or fileobj needs to be provided.")
|
||||||
|
|
@ -302,6 +302,11 @@ class Client(requests.Session):
|
||||||
if utils.compare_version('1.8', self._version) >= 0:
|
if utils.compare_version('1.8', self._version) >= 0:
|
||||||
stream = True
|
stream = True
|
||||||
|
|
||||||
|
if dockerfile and utils.compare_version('1.17', self._version) < 0:
|
||||||
|
raise errors.InvalidVersion(
|
||||||
|
'dockerfile was only introduced in API version 1.17'
|
||||||
|
)
|
||||||
|
|
||||||
u = self._url('/build')
|
u = self._url('/build')
|
||||||
params = {
|
params = {
|
||||||
't': tag,
|
't': tag,
|
||||||
|
|
@ -310,7 +315,8 @@ class Client(requests.Session):
|
||||||
'nocache': nocache,
|
'nocache': nocache,
|
||||||
'rm': rm,
|
'rm': rm,
|
||||||
'forcerm': forcerm,
|
'forcerm': forcerm,
|
||||||
'pull': pull
|
'pull': pull,
|
||||||
|
'dockerfile': dockerfile
|
||||||
}
|
}
|
||||||
|
|
||||||
if context is not None:
|
if context is not None:
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ correct value (e.g `gzip`).
|
||||||
* encoding (str): The encoding for a stream. Set to `gzip` for compressing
|
* encoding (str): The encoding for a stream. Set to `gzip` for compressing
|
||||||
* pull (bool): Downloads any updates to the FROM image in Dockerfiles
|
* pull (bool): Downloads any updates to the FROM image in Dockerfiles
|
||||||
* forcerm (bool): Always remove intermediate containers, even after unsuccessful builds
|
* forcerm (bool): Always remove intermediate containers, even after unsuccessful builds
|
||||||
|
* dockerfile (str): path within the build context to the Dockerfile
|
||||||
|
|
||||||
**Returns** (generator): A generator of the build output
|
**Returns** (generator): A generator of the build output
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2095,6 +2095,12 @@ class DockerClientTest(Cleanup, unittest.TestCase):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.fail('Command should not raise exception: {0}'.format(e))
|
self.fail('Command should not raise exception: {0}'.format(e))
|
||||||
|
|
||||||
|
def test_build_container_with_named_dockerfile(self):
|
||||||
|
try:
|
||||||
|
self.client.build('.', dockerfile='nameddockerfile')
|
||||||
|
except Exception as e:
|
||||||
|
self.fail('Command should not raise exception: {0}'.format(e))
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# PY SPECIFIC TESTS #
|
# PY SPECIFIC TESTS #
|
||||||
#######################
|
#######################
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue