-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding build and updating git ignore for .image #569
- Loading branch information
Matthew Letter
committed
Feb 9, 2016
1 parent
bad2f26
commit a2c3483
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import argparse | ||
import datetime | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
# Get the current commit and time. | ||
commit = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE).communicate()[0].strip()[:8] | ||
timestamp = datetime.datetime.now() | ||
|
||
def build_image(image): | ||
subprocess.check_call(["docker", "build", "--no-cache=%s" % ("true" if arguments.no_cache else "false"), "-t", "sandialabs/%s" % image, image]) | ||
|
||
def save_image(image): | ||
saved_image = "%s-%s-%s.image" % (image, timestamp.strftime("%Y%m%dT%H%M"), commit) | ||
sys.stderr.write("Saving image %s as %s.\n" % (image, saved_image)) | ||
subprocess.check_call(["docker", "save", "-o", saved_image, "sandialabs/%s" % image]) | ||
|
||
def build_slycat_base(): | ||
build_image("slycat-base") | ||
|
||
def build_slycat_developer(): | ||
build_slycat_base() | ||
build_image("slycat-developer") | ||
|
||
def slycat_developer_image(): | ||
build_slycat_developer() | ||
save_image("slycat-developer") | ||
|
||
targets = { | ||
"slycat-developer": build_slycat_developer, | ||
"slycat-developer-image": slycat_developer_image, | ||
} | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--no-cache", action="store_true", help="Don't use existing cached images.") | ||
parser.add_argument("target", choices=targets.keys(), help="Target to build.") | ||
arguments = parser.parse_args() | ||
|
||
targets[arguments.target]() | ||
|