Skip to content

Commit

Permalink
adding build and updating git ignore for .image #569
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Letter committed Feb 9, 2016
1 parent 5a0a4cf commit b10fdbf
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ web-server/config.ini
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

*.iml
*.image

## Directory-based project format:
.idea/
Expand Down
41 changes: 41 additions & 0 deletions open-source-docker/docker/open-source-build/build.py
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]()

0 comments on commit b10fdbf

Please sign in to comment.