Пример #1
0
def build_docker(dockername, dirname, verbose=False, nocache=False, archtype=None):
    # docker name is designed to use lower case.
    dockername = dockername.lower()
    dockertag = dockername
    if archtype is not None and archtype != "amd64":
        dockertag = dockername + "-" + archtype

    dockerfile_name = get_dockerfile(dirname, archtype)
    print("Prepare to build docker with file: " + dockerfile_name)

    if verbose:
        print("Building docker ... " + dockertag + " .. @" + dirname)
    with cd(dirname):
        # print "Test if prebuid.sh exists"
        if os.path.exists("prebuild.sh"):
            print("Execute prebuild.sh for docker %s" % dockername)
            os.system("bash prebuild.sh")
        if nocache:
            cmd = "docker build --no-cache -f " + dockerfile_name + " -t "+ dockertag + " ."
        else:
            cmd = "docker build -f " + dockerfile_name + " -t "+ dockertag + " ."
        if verbose:
            print(cmd)
        os.system(cmd)
    return dockername
Пример #2
0
def build_docker(dockername, dirname, verbose=False, nocache=False):

    # docker name is designed to use lower case.
    dockername = dockername.lower()
    if verbose:
        print "Building docker ... " + dockername + " .. @" + dirname

    with cd(dirname):
        Logger().cmd("cd " + dirname)

        # print "Test if prebuid.sh exists"
        if os.path.exists("prebuild.sh"):
            print "Execute prebuild.sh for docker %s" % dockername

            cmd = "bash prebuild.sh"
            os.system(cmd)
            Logger().cmd(cmd)

        if nocache:
            cmd = "docker build --no-cache -t " + dockername + " ."
        else:
            cmd = "docker build -t " + dockername + " ."

        if verbose:
            print cmd

        os.system(cmd)
        Logger().cmd(cmd)

    return dockername
Пример #3
0
def build_docker(dockername, dirname, verbose=False, nocache=False):
    # docker name is designed to use lower case.
    dockername = dockername.lower()
    if verbose:
        print("Building docker ... " + dockername + " .. @" + dirname)

    try:
        output = subprocess.check_output(["git", "rev-parse", "HEAD"])
        git_hash = output.decode("utf-8").strip()
    except Exception:
        git_hash = "unknown"

    with cd(dirname):
        # print "Test if prebuid.sh exists"
        if os.path.exists("prebuild.sh"):
            print("Execute prebuild.sh for docker %s" % dockername)
            os.system("bash prebuild.sh")

        build_args = "--build-arg GIT_HASH=%s" % (git_hash)

        if nocache:
            build_args += " --no-cache"

        cmd = "docker build %s -t %s ." % (build_args, dockername)

        if verbose:
            print(cmd)
        os.system(cmd)
    return dockername