Skip to content

Commit

Permalink
Merge pull request #118 from bacongobbler/buildargs
Browse files Browse the repository at this point in the history
fix(deploy): inject DOCKER_BUILD_ARGS into the Dockerfile
  • Loading branch information
Matthew Fisher authored Mar 2, 2017
2 parents a2600e1 + 13b2463 commit 8eb4428
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rootfs/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ def download_file(tar_path):
with tarfile.open("apptar", "r:gz") as tar:
tar.extractall("/app/")
log("extracting tar file complete")
buildargs = json.loads(os.getenv('DOCKER_BUILD_ARGS', '{}'))
# inject docker build args into the Dockerfile so we get around Dockerfiles that don't have things
# like PORT defined.
with open("/app/Dockerfile", "a") as dockerfile:
# ensure we are on a new line
dockerfile.write("\n")
for envvar in buildargs:
dockerfile.write("ARG {}\n".format(envvar))
client = docker.Client(version='auto')
if registryLocation != "on-cluster":
registry = os.getenv('DEIS_REGISTRY_HOSTNAME', 'https://index.docker.io/v1/')
Expand All @@ -112,7 +120,7 @@ def download_file(tar_path):
rm=True,
pull=True,
path='/app',
buildargs=json.loads(os.getenv('DOCKER_BUILD_ARGS', '{}')))
buildargs=buildargs)
log_output(stream, True)
print("Pushing to registry")
stream = client.push(registry+'/'+imageName, tag=imageTag, stream=True)
Expand Down

0 comments on commit 8eb4428

Please sign in to comment.