mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
docker-build: added support for 'maintainer' keyword
This commit is contained in:
parent
957c500ac9
commit
038ca5ee39
2 changed files with 11 additions and 8 deletions
|
@ -49,26 +49,27 @@ def docker(args, stdin=None):
|
||||||
def image_exists(img):
|
def image_exists(img):
|
||||||
return docker(["inspect", img]).read().strip() != ""
|
return docker(["inspect", img]).read().strip() != ""
|
||||||
|
|
||||||
def run_and_commit(img_in, cmd, stdin=None):
|
def run_and_commit(img_in, cmd, stdin=None, author=None):
|
||||||
run_id = docker(["run"] + (["-i", "-a", "stdin"] if stdin else ["-d"]) + [img_in, "/bin/sh", "-c", cmd], stdin=stdin).read().rstrip()
|
run_id = docker(["run"] + (["-i", "-a", "stdin"] if stdin else ["-d"]) + [img_in, "/bin/sh", "-c", cmd], stdin=stdin).read().rstrip()
|
||||||
print "---> Waiting for " + run_id
|
print "---> Waiting for " + run_id
|
||||||
result=int(docker(["wait", run_id]).read().rstrip())
|
result=int(docker(["wait", run_id]).read().rstrip())
|
||||||
if result != 0:
|
if result != 0:
|
||||||
print "!!! '{}' return non-zero exit code '{}'. Aborting.".format(cmd, result)
|
print "!!! '{}' return non-zero exit code '{}'. Aborting.".format(cmd, result)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
return docker(["commit", run_id]).read().rstrip()
|
return docker(["commit"] + (["-author", author] if author else []) + [run_id]).read().rstrip()
|
||||||
|
|
||||||
def insert(base, src, dst):
|
def insert(base, src, dst, author=None):
|
||||||
print "COPY {} to {} in {}".format(src, dst, base)
|
print "COPY {} to {} in {}".format(src, dst, base)
|
||||||
if dst == "":
|
if dst == "":
|
||||||
raise Exception("Missing destination path")
|
raise Exception("Missing destination path")
|
||||||
stdin = file(src)
|
stdin = file(src)
|
||||||
stdin.seek(0)
|
stdin.seek(0)
|
||||||
return run_and_commit(base, "cat > {0}; chmod +x {0}".format(dst), stdin=stdin)
|
return run_and_commit(base, "cat > {0}; chmod +x {0}".format(dst), stdin=stdin, author=author)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
base=""
|
base=""
|
||||||
|
maintainer=""
|
||||||
steps = []
|
steps = []
|
||||||
try:
|
try:
|
||||||
for line in sys.stdin.readlines():
|
for line in sys.stdin.readlines():
|
||||||
|
@ -77,19 +78,20 @@ def main():
|
||||||
if line == "" or line[0] == "#":
|
if line == "" or line[0] == "#":
|
||||||
continue
|
continue
|
||||||
op, param = line.split(" ", 1)
|
op, param = line.split(" ", 1)
|
||||||
|
print op.upper() + " " + param
|
||||||
if op == "from":
|
if op == "from":
|
||||||
print "FROM " + param
|
|
||||||
base = param
|
base = param
|
||||||
steps.append(base)
|
steps.append(base)
|
||||||
|
elif op == "maintainer":
|
||||||
|
maintainer = param
|
||||||
elif op == "run":
|
elif op == "run":
|
||||||
print "RUN " + param
|
result = run_and_commit(base, param, author=maintainer)
|
||||||
result = run_and_commit(base, param)
|
|
||||||
steps.append(result)
|
steps.append(result)
|
||||||
base = result
|
base = result
|
||||||
print "===> " + base
|
print "===> " + base
|
||||||
elif op == "copy":
|
elif op == "copy":
|
||||||
src, dst = param.split(" ", 1)
|
src, dst = param.split(" ", 1)
|
||||||
result = insert(base, src, dst)
|
result = insert(base, src, dst, author=maintainer)
|
||||||
steps.append(result)
|
steps.append(result)
|
||||||
base = result
|
base = result
|
||||||
print "===> " + base
|
print "===> " + base
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# Start build from a know base image
|
# Start build from a know base image
|
||||||
|
maintainer Solomon Hykes <solomon@dotcloud.com>
|
||||||
from base:ubuntu-12.10
|
from base:ubuntu-12.10
|
||||||
# Update ubuntu sources
|
# Update ubuntu sources
|
||||||
run echo 'deb http://archive.ubuntu.com/ubuntu quantal main universe multiverse' > /etc/apt/sources.list
|
run echo 'deb http://archive.ubuntu.com/ubuntu quantal main universe multiverse' > /etc/apt/sources.list
|
||||||
|
|
Loading…
Add table
Reference in a new issue