def installProgram(programName, useCache): """ Build the docker image associated with a program and create a tiny executable to add that image to your path. """ print("Installing {0} ...".format(programName)) dockerImageDir = os.path.join(paths.getProgramSrcDir(programName), "docker-image") _DockerfilePath = os.path.join(dockerImageDir, 'Dockerfile') # Check if we use a 'Dockerfile' or a 'MakeBaseImage.sh' if os.path.isfile(paths.getMakeBaseImageScriptPath(programName)): installFromBaseImage(programName, cacheArg) elif os.path.isfile(_DockerfilePath): if useCache: cacheArg = "--no-cache=false" else: cacheArg = "--no-cache=true" docker.runDockerAndExitIfItFails(["build","-rm",cacheArg,"--tag=subuser-"+programName+"",dockerImageDir]) else: sys.exit("No buildfile found: need one of: 'Dockerfile' or 'MakeBaseImage.sh'. PATH: {0}".format(dockerImageDir)) _permissions = permissions.getPermissions(programName) # Create a small executable that just calls the real executable in the docker image. if 'executable' in _permissions: installExecutable(programName) try: lastUpdateTime = _permissions["last-update-time"] except KeyError: lastUpdateTime = installTime.currentTimeString() imageID = dockerImages.getImageID("subuser-{0}".format(programName)) registry.registerProgram(programName, lastUpdateTime, imageID)
def installFromDockerfile(programName, programSrcDir, useCache): if useCache: cacheArg = "--no-cache=false" else: cacheArg = "--no-cache=true" dockerImageDir = os.path.join(programSrcDir,"docker-image") docker.runDockerAndExitIfItFails(["build","--rm",cacheArg,"--tag=subuser-"+programName+"",dockerImageDir])