blob: 1641cbdc0431ebf6e297e1f91649ad2ab3c50e69 [file] [log] [blame]
package com.mirantis.mk
/**
*
* Docker functions
*
*/
/**
* Build step to build docker image.
*
* @param img Image name
* @param baseImg Base image to use (can be empty)
* @param dockerFile Dockerfile to use
* @param timestamp Image tag
* @param params Other parameters for docker
* @return "docker app" - result of docker.build
*/
def buildDockerImage(img, baseImg, dockerFile, timestamp, params=[]) {
def imageDir = dockerFile.substring(0, dockerFile.lastIndexOf("/"))
if (baseImg) {
sh "git checkout -f ${dockerFile}; sed -i -e 's,^FROM.*,FROM ${baseImg},g' ${dockerFile}"
}
params << "-f ${dockerFile}"
params << imageDir
return docker.build(
"${img}:${timestamp}",
params.join(' ')
)
}