Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save khauser/258b722c82648554ab89c75435f35121 to your computer and use it in GitHub Desktop.
Save khauser/258b722c82648554ab89c75435f35121 to your computer and use it in GitHub Desktop.
apply plugin: 'application'
apply plugin: 'docker'
import org.apache.tools.ant.taskdefs.condition.Os
def DOCKER_REPO = "klhauser"
task buildDockerImage(type: Docker) {
tagVersion = 'latest'
tag = DOCKER_REPO + "/lessoria-" + jar.baseName
push = project.hasProperty('push')
addFile {
from jar
rename {'app.jar'}
}
entryPoint(['java', '-Djava.security.egd=file:/dev/./urandom', '-Dspring.profiles.active=docker', '-jar', '/app.jar'])
}
task upDockerCompose (type: Exec) {
//dependsOn buildDockerImage
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine "cmd", "/c", "docker-compose", "up", "-d"
}
else {
commandLine "docker-compose", "up", "-d"
}
}
upDockerCompose.doLast {
sleep(30 * 1000)
}
task downDockerCompose (type: Exec) {
//dependsOn buildDockerImage
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine "cmd", "/c", "docker-compose", "down"
}
else {
commandLine "docker-compose", "down"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment