mirror of https://github.com/docker/docker-py.git
Merge pull request #502 from cpuguy83/498_dockerignore_special_names
Add special cases for .dockerignore
This commit is contained in:
commit
39ee5981b4
|
@ -297,6 +297,12 @@ class Client(requests.Session):
|
||||||
if os.path.exists(dockerignore):
|
if os.path.exists(dockerignore):
|
||||||
with open(dockerignore, 'r') as f:
|
with open(dockerignore, 'r') as f:
|
||||||
exclude = list(filter(bool, f.read().split('\n')))
|
exclude = list(filter(bool, f.read().split('\n')))
|
||||||
|
# These are handled by the docker daemon and should not be
|
||||||
|
# excluded on the client
|
||||||
|
if 'Dockerfile' in exclude:
|
||||||
|
exclude.remove('Dockerfile')
|
||||||
|
if '.dockerignore' in exclude:
|
||||||
|
exclude.remove(".dockerignore")
|
||||||
context = utils.tar(path, exclude=exclude)
|
context = utils.tar(path, exclude=exclude)
|
||||||
|
|
||||||
if utils.compare_version('1.8', self._version) >= 0:
|
if utils.compare_version('1.8', self._version) >= 0:
|
||||||
|
|
|
@ -1325,6 +1325,8 @@ class TestBuildWithDockerignore(Cleanup, BaseTestCase):
|
||||||
with open(os.path.join(base_dir, '.dockerignore'), 'w') as f:
|
with open(os.path.join(base_dir, '.dockerignore'), 'w') as f:
|
||||||
f.write("\n".join([
|
f.write("\n".join([
|
||||||
'node_modules',
|
'node_modules',
|
||||||
|
'Dockerfile',
|
||||||
|
'.dockerginore',
|
||||||
'', # empty line
|
'', # empty line
|
||||||
]))
|
]))
|
||||||
|
|
||||||
|
@ -1343,6 +1345,8 @@ class TestBuildWithDockerignore(Cleanup, BaseTestCase):
|
||||||
chunk = chunk.decode('utf-8')
|
chunk = chunk.decode('utf-8')
|
||||||
logs += chunk
|
logs += chunk
|
||||||
self.assertFalse('node_modules' in logs)
|
self.assertFalse('node_modules' in logs)
|
||||||
|
self.assertFalse('Dockerfile' in logs)
|
||||||
|
self.assertFalse('.dockerginore' in logs)
|
||||||
self.assertTrue('not-ignored' in logs)
|
self.assertTrue('not-ignored' in logs)
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
|
|
Loading…
Reference in New Issue