| Sergey Kolekonov | ba20398 | 2016-12-21 18:32:17 +0400 | [diff] [blame] | 1 | package com.mirantis.mk | 
|  | 2 |  | 
|  | 3 | /** | 
|  | 4 | * | 
|  | 5 | * Docker functions | 
|  | 6 | * | 
|  | 7 | */ | 
|  | 8 |  | 
|  | 9 | /** | 
|  | 10 | * Build step to build docker image. For use with eg. parallel | 
|  | 11 | * | 
|  | 12 | * @param img           Image name | 
|  | 13 | * @param baseImg       Base image to use (can be empty) | 
|  | 14 | * @param dockerFile    Dockerfile to use | 
|  | 15 | * @param timestamp     Image tag | 
|  | 16 | */ | 
|  | 17 | def buildDockerImageStep(img, baseImg, dockerFile, timestamp) { | 
|  | 18 | File df = new File(dockerfile); | 
|  | 19 | return { | 
|  | 20 | if (baseImg) { | 
|  | 21 | sh "git checkout -f ${dockerfile}; sed -i -e 's,^FROM.*,FROM ${baseImg},g' ${dockerFile}" | 
|  | 22 | } | 
|  | 23 | docker.build( | 
|  | 24 | "${img}:${timestamp}", | 
|  | 25 | [ | 
|  | 26 | "-f ${dockerFile}", | 
|  | 27 | df.getParent() | 
|  | 28 | ].join(' ') | 
|  | 29 | ) | 
|  | 30 | } | 
|  | 31 | } |