-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
104 lines (84 loc) · 2.47 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
allprojects {
apply plugin: 'java'
apply plugin: 'idea'
repositories {
mavenCentral()
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:3.2.1'
classpath 'org.hidetake:gradle-ssh-plugin:2.9.0'
}
}
/*******************************
* DOCKER Tasks
*******************************/
apply plugin: 'com.bmuschko.docker-remote-api'
import com.bmuschko.gradle.docker.tasks.image.*
import com.bmuschko.gradle.docker.tasks.container.*
docker {
// provide a url that Docker Remote API is enable
url = 'tcp://eseliktay-mbp15.local.:2376'
String springRestContainerName = System.getProperty('springRestContainerName', 'spring-rest')
task buildSpringBootRestImage(type: DockerBuildImage) {
group = 'Docker'
inputDir = file('.')
tag = 'erolstt/spring-rest-demo:latest'
}
task createRestAPIContainer(type: DockerCreateContainer) {
group = 'Docker'
containerName = springRestContainerName
dependsOn buildSpringBootRestImage
targetImageId { buildSpringBootRestImage.getImageId() }
portBindings = ['8080:8080']
}
task startRestAPIContainer(type: DockerStartContainer) {
group = 'Docker'
dependsOn createRestAPIContainer
targetContainerId { createRestAPIContainer.getContainerId() }
}
task stopRestAPIContainer(type: DockerStopContainer) {
group = 'Docker'
targetContainerId { springRestContainerName }
}
task removeRestAPIContainer(type: DockerRemoveContainer) {
dependsOn stopRestAPIContainer
group = 'Docker'
targetContainerId { springRestContainerName }
}
task removeSpringBootRestImage(type: DockerRemoveImage) {
group = 'Docker'
targetImageId { buildSpringBootRestImage.tag }
}
}
/*******************************
* SSH Tasks
*******************************/
apply plugin: 'org.hidetake.ssh'
remotes {
linuxServer {
host = linuxHost
user = linuxUser
password = linuxPassword
}
}
ssh.settings {
knownHosts = allowAnyHosts
}
task createSpringRestImage {
group 'ssh'
description ''
doLast {
println 'Host Name : ' + linuxHost
println 'User Name : ' + linuxUser
ssh.run {
session(remotes.linuxServer) {
execute 'docker build -t spring-rest-hello-world:0.1 .'
}
}
}
}