Skip to content

Instantly share code, notes, and snippets.

@ptaylor
Created January 9, 2018 14:55
Show Gist options
  • Save ptaylor/8917a4e034d538a63b73e6bebdc423ca to your computer and use it in GitHub Desktop.
Save ptaylor/8917a4e034d538a63b73e6bebdc423ca to your computer and use it in GitHub Desktop.
Gradle build docker image with multiple tags
// Using two docker builds as a workaround until multiple tags are
// supported (https://github.com/Transmode/gradle-docker/issues/50).
task createDockerTasks() {
buildDockerWithTag('latest')
buildDockerWithTag(version)
}
task buildDocker(dependsOn: [createDockerTasks, buildDocker_latest, "buildDocker_${version}"]) {
}
def buildDockerWithTag(tag) {
return tasks.create("buildDocker_${tag}", Docker) {
println "build docker with tag ${tag}"
applicationName = "${project.group}/${jar.baseName}"
tagVersion = tag
setEnvironment('JAVA_OPTS', docker_java_opts)
addFile('src/main/resources/docker/start.sh', "/data/")
addFile(jar.archivePath, "/data/")
entryPoint(['sh', "/data/start.sh", "/data/${jar.archiveName}"])
push = docker_push == 'true'
registry docker_registry
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment