Created
January 9, 2018 14:55
-
-
Save ptaylor/8917a4e034d538a63b73e6bebdc423ca to your computer and use it in GitHub Desktop.
Gradle build docker image with multiple tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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