Advertisement
Guest User

Untitled

a guest
May 26th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. apply plugin: 'application'
  2. apply plugin: 'docker'
  3.  
  4. import org.apache.tools.ant.taskdefs.condition.Os
  5.  
  6. def DOCKER_REPO = "klhauser"
  7. task buildDockerImage(type: Docker) {
  8. tagVersion = 'latest'
  9. tag = DOCKER_REPO + "/lessoria-" + jar.baseName
  10. push = project.hasProperty('push')
  11. addFile {
  12. from jar
  13. rename {'app.jar'}
  14. }
  15. entryPoint(['java', '-Djava.security.egd=file:/dev/./urandom', '-Dspring.profiles.active=docker', '-jar', '/app.jar'])
  16. }
  17.  
  18. task upDockerCompose (type: Exec) {
  19. //dependsOn buildDockerImage
  20. if (Os.isFamily(Os.FAMILY_WINDOWS)) {
  21. commandLine "cmd", "/c", "docker-compose", "up", "-d"
  22. }
  23. else {
  24. commandLine "docker-compose", "up", "-d"
  25. }
  26. }
  27.  
  28. upDockerCompose.doLast {
  29. sleep(30 * 1000)
  30. }
  31.  
  32. task downDockerCompose (type: Exec) {
  33. //dependsOn buildDockerImage
  34. if (Os.isFamily(Os.FAMILY_WINDOWS)) {
  35. commandLine "cmd", "/c", "docker-compose", "down"
  36. }
  37. else {
  38. commandLine "docker-compose", "down"
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement