Skip to content
Snippets Groups Projects
Commit 33ba39d0 authored by Georges Racinet's avatar Georges Racinet
Browse files

Heptapod build-launch: common function for builds

Removing duplication is always a good thing, and
in particular, makes these sequences of operations
controlled by boolean flags easier to follow.
Here this exposes a bug.
parent c7e2ca3a
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,20 @@
print(fmt % (line_elts[0] + ':', line_elts[1]))
def build_image(full_tag, context_dir, simulate=False,
msg="Docker build command"):
"""Build the image from `context_dir` and tag it.
`full_tag` is actually the full name of the image, with the tag part.
Examples: `octobus/heptaopd-dev:latest`
"""
cmd = ('docker', 'build', '-t', full_tag, context_dir)
print("%s: %r" % (msg, cmd))
if not simulate:
subprocess.check_call(cmd)
print()
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
......@@ -65,8 +79,8 @@
img_group = parser.add_argument_group("Docker image options")
img_group.add_argument('--image-tag',
default="octobus/heptapod-dev:latest",
help="Tag for the produced image. The default is "
"suitable for pushing to Docker Hub.")
help="Tag for the produced and/or run image. "
"The default is suitable for pushing to Docker Hub.")
img_group.add_argument('--build-base-image', action="store_true",
help="Build or rebuild the octobus/heptapod image "
"upon which the development image is based.")
......@@ -86,12 +100,8 @@
('Logs', log_vol),
('Sources', src_vol),
))
base_build_cmd = ['docker', 'build',
'-t', 'octobus/heptapod:latest',
os.path.join(OMNIBUS_DIR, 'heptapod_docker')]
print("Docker base image build command: %r" % base_build_cmd)
if not simulate:
subprocess.check_call(base_build_cmd)
print()
build_image('octobus/heptapod:latest',
os.path.join(OMNIBUS_DIR, 'heptapod_docker'),
simulate=simulate,
msg="Docker base image build command")
......@@ -97,12 +107,6 @@
build_cmd = ['docker', 'build',
'-t', parsed_args.image_tag,
DOCKER_ENV_DIR]
print("Docker build command: %r" % build_cmd)
if not simulate:
subprocess.check_call(build_cmd)
print()
image_tag = parsed_args.image_tag
build_image(image_tag, DOCKER_ENV_DIR, simulate=simulate)
run_cmd = ['docker', 'run', '--detach',
'--hostname', 'heptapod',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment