Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update image local build script #14599

Merged
merged 3 commits into from Jun 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions hack/build-local-images.py
Expand Up @@ -5,6 +5,7 @@
from subprocess import call
from tempfile import mkdtemp

from atexit import register
from os import getenv, mkdir, remove
from os.path import abspath, dirname, exists, join

Expand Down Expand Up @@ -105,7 +106,7 @@ def add_to_context(context_dir, source, destination, container_destination):
to place it in the container file-
sytem at the correct destination.
"""
debug("Adding file:\n\tfrom {}\n\tto {},\n\tincluding in container at {}".format(
debug("Adding file:\n\tfrom {}\n\tto {}\n\tincluding in container at {}".format(
source,
join(context_dir, destination),
container_destination)
Expand All @@ -127,6 +128,8 @@ def debug(message):
os_image_path = join(os_root, "images")

context_dir = mkdtemp()
register(rmtree, context_dir)

debug("Created temporary context dir at {}".format(context_dir))
mkdir(join(context_dir, "bin"))
mkdir(join(context_dir, "src"))
Expand All @@ -137,7 +140,7 @@ def debug(message):

print "[INFO] Building {}...".format(image)
with open(join(context_dir, "Dockerfile"), "w+") as dockerfile:
dockerfile.write("FROM {}\n".format(image))
dockerfile.write("FROM {}\n".format(full_name(image)))

config = image_config[image]
for binary in config.get("binaries", []):
Expand All @@ -148,6 +151,7 @@ def debug(message):
container_destination=config["binaries"][binary]
)

mkdir(join(context_dir, "src", image))
for file in config.get("files", []):
add_to_context(
context_dir,
Expand All @@ -161,5 +165,3 @@ def debug(message):

remove(join(context_dir, "Dockerfile"))
rmtree(join(context_dir, "src", image))

rmtree(context_dir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we want this cleanup?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's atexit