summaryrefslogtreecommitdiff
path: root/docker/api/build.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-04-12 12:38:27 -0700
committerJoffrey F <joffrey@docker.com>2018-04-12 13:10:21 -0700
commit17bf6f71c822c6e768e377f8f675c8094994bba5 (patch)
treedca48fcc20bedcc38e9d50c31a5e9e5d3e0c0849 /docker/api/build.py
parent16751ac509b4bbe75293847fe87099ff51a74013 (diff)
downloaddocker-py-c5869-dockerfile-abspath.tar.gz
Support absolute paths for in-context Dockerfilesc5869-dockerfile-abspath
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/api/build.py')
-rw-r--r--docker/api/build.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/docker/api/build.py b/docker/api/build.py
index d69985e..a76e32c 100644
--- a/docker/api/build.py
+++ b/docker/api/build.py
@@ -316,10 +316,12 @@ 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
+ return (os.path.relpath(abs_dockerfile, path), None)