-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
84 lines (69 loc) · 2.36 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
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
import com.bmuschko.gradle.docker.tasks.image.DockerPushImage
import com.bmuschko.gradle.docker.DockerRegistryCredentials
buildscript {
ext {
springBootVersion = '1.5.3.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'com.bmuschko:gradle-docker-plugin:3.0.6'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'com.bmuschko.docker-remote-api'
ext {
dockerPath = "${project.buildDir}/docker"
}
version = '1.0'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
bootRun {
addResources = true
}
docker {
url = project.properties.getOrDefault('dockerUrl', System.env.DOCKER_HOST)
certPath = new File(project.properties.getOrDefault('certPath', System.env.DOCKER_CERT_PATH))
registryCredentials {
url = DockerRegistryCredentials.DEFAULT_URL
username = "horzsolt"
password = "l5ddemo"
email = "[email protected]"
}
}
task prepareArchiveForDockerBuild(type: Copy) {
from "${project.jar.archivePath}"
into "$dockerPath"
}
task createDockerfile(type: Dockerfile, dependsOn: [build, 'prepareArchiveForDockerBuild']) {
destFile = project.file("$dockerPath/Dockerfile")
from 'frolvlad/alpine-oraclejdk8:slim'
volume '/tmp'
addFile "${project.jar.archiveName}", 'app.jar'
runCommand "sh -c 'touch /app.jar'"
// environmentVariable 'JAVA_OPTS', " "
entryPoint "sh", "-c", 'java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar'
}
task buildImage(type: DockerBuildImage, dependsOn: 'createDockerfile') {
tag = 'hub.docker.com/horzsolt/l5ddemo'
inputDir = createDockerfile.destFile.parentFile
}
task pushImage(type: DockerPushImage, dependsOn: 'buildImage') {
imageName = 'horzsolt/l5ddemo'
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-devtools')
testCompile('org.springframework.boot:spring-boot-starter-test')
}