-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
90 lines (74 loc) · 2.17 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
import com.bmuschko.gradle.docker.tasks.container.*
import com.bmuschko.gradle.docker.tasks.image.*
buildscript {
ext {
springBootVersion = '1.2.3.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("io.spring.gradle:dependency-management-plugin:0.4.1.RELEASE")
classpath("com.bmuschko:gradle-docker-plugin:2.2")
}
}
repositories {
mavenCentral()
jcenter()
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.bmuschko.docker-remote-api'
jar {
baseName = 'docker-poc'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
dependencies {
compile("org.springframework.boot:spring-boot-starter-actuator")
compile("org.springframework.boot:spring-boot-starter-ws")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile group: 'junit', name: 'junit', version: '4.11'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
task copyBootJarsToDocker(type: Copy) {
dependsOn bootRepackage
from "$buildDir/libs"
into 'build/docker/'
}
/**
* Docker related
*/
docker {
url = 'https://192.168.59.103:2376'
}
task createDockerFile(type: Dockerfile) {
dependsOn copyBootJarsToDocker
destFile = project.file('build/docker/Dockerfile')
from 'dockerfile/java:oracle-java7'
maintainer 'Alexandru Ionita [email protected]'
copyFile('docker-poc-0.0.1-SNAPSHOT.jar', '/app/app.jar')
exposePort 8080
defaultCommand('java', '-jar', '/app/app.jar')
}
task buildImage(type: DockerBuildImage) {
dependsOn createDockerFile
inputDir = createDockerFile.destFile.parentFile
tag = "igenox/docker-poc"
}
task createAppContainer(type: DockerCreateContainer) {
dependsOn buildImage
targetImageId { buildImage.getImageId() }
}
task startAppContainer(type: DockerStartContainer) {
dependsOn createAppContainer
targetContainerId { createAppContainer.getContainerId() }
portBindings = ['8080:8080']
}