Skip to content

Commit 8eb4428

Browse files
author
Matthew Fisher
authored
Merge pull request #118 from bacongobbler/buildargs
fix(deploy): inject DOCKER_BUILD_ARGS into the Dockerfile
2 parents a2600e1 + 13b2463 commit 8eb4428

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

rootfs/deploy.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ def download_file(tar_path):
9696
with tarfile.open("apptar", "r:gz") as tar:
9797
tar.extractall("/app/")
9898
log("extracting tar file complete")
99+
buildargs = json.loads(os.getenv('DOCKER_BUILD_ARGS', '{}'))
100+
# inject docker build args into the Dockerfile so we get around Dockerfiles that don't have things
101+
# like PORT defined.
102+
with open("/app/Dockerfile", "a") as dockerfile:
103+
# ensure we are on a new line
104+
dockerfile.write("\n")
105+
for envvar in buildargs:
106+
dockerfile.write("ARG {}\n".format(envvar))
99107
client = docker.Client(version='auto')
100108
if registryLocation != "on-cluster":
101109
registry = os.getenv('DEIS_REGISTRY_HOSTNAME', 'https://index.docker.io/v1/')
@@ -112,7 +120,7 @@ def download_file(tar_path):
112120
rm=True,
113121
pull=True,
114122
path='/app',
115-
buildargs=json.loads(os.getenv('DOCKER_BUILD_ARGS', '{}')))
123+
buildargs=buildargs)
116124
log_output(stream, True)
117125
print("Pushing to registry")
118126
stream = client.push(registry+'/'+imageName, tag=imageTag, stream=True)

0 commit comments

Comments
 (0)