Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update image local build script (#14599)
* Use the full image name for local image build FROM

When we are writing the `FROM` statement for the local image build
Dockerfile, we need to use the fully qualified name of the image we
are building on top of.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>

* Ensure local image tmp dirs are cleaned up on error

When the script fails to build an image, we need to ensure that the temp
directory we created for context is cleaned up anyway. Trapping the
functionality on exit is the appropriate way to acheive this.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>

* Removed extraneous comma from local build debugging output

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
  • Loading branch information
stevekuznetsov authored and bparees committed Jun 12, 2017
1 parent 5f29c22 commit fcd56bc
Showing 1 changed file with 6 additions and 4 deletions.
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)

0 comments on commit fcd56bc

Please sign in to comment.