Implemented new version of docker build step function
Change-Id: Icb9e9e437d54c0b7eb80fb672299524b813b7549
diff --git a/src/com/mirantis/mk/Docker.groovy b/src/com/mirantis/mk/Docker.groovy
index 5ea83ee..73ef359 100644
--- a/src/com/mirantis/mk/Docker.groovy
+++ b/src/com/mirantis/mk/Docker.groovy
@@ -7,25 +7,24 @@
*/
/**
- * Build step to build docker image. For use with eg. parallel
+ * 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
+ * @return "docker app" - result of docker.build
*/
def buildDockerImageStep(img, baseImg, dockerFile, timestamp) {
- File df = new File(dockerfile);
- return {
- if (baseImg) {
- sh "git checkout -f ${dockerfile}; sed -i -e 's,^FROM.*,FROM ${baseImg},g' ${dockerFile}"
- }
- docker.build(
- "${img}:${timestamp}",
- [
- "-f ${dockerFile}",
- df.getParent()
- ].join(' ')
- )
+ def imageDir = dockerFile.substring(0, dockerFile.lastIndexOf("/"))
+ if (baseImg) {
+ sh "git checkout -f ${dockerFile}; sed -i -e 's,^FROM.*,FROM ${baseImg},g' ${dockerFile}"
}
+ return docker.build(
+ "${img}:${timestamp}",
+ [
+ "-f ${dockerFile}",
+ imageDir
+ ].join(' ')
+ )
}