-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.gradle
67 lines (55 loc) · 1.57 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
group = 'org.javaee.sample'
version = '1.0-SNAPSHOT'
apply plugin: 'war'
apply plugin: 'com.bmuschko.docker-remote-api'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:3.0.3'
}
}
import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer
import com.bmuschko.gradle.docker.tasks.container.DockerStartContainer
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
sourceCompatibility = 1.8
targetCompatibility = 1.8
configurations {
dockerJava {
resolutionStrategy {
force 'de.gesellix:unix-socket-factory:2016-04-06T22-21-19'
}
}
}
docker {
url = 'unix:///var/run/docker.sock'
}
dependencies {
providedCompile group: 'javax', name: 'javaee-api', version:'7.0'
}
task copyDockerArtifacts(type: Copy) {
dependsOn build
from('build/libs') {
include "javaee-docker-gradle-${project.version}.war"
}
from('src/main/docker') {
include 'Dockerfile'
}
into 'build/docker'
rename "javaee-docker-gradle-${project.version}.war", 'javaee-docker-gradle.war'
}
task buildImage(type: DockerBuildImage) {
dependsOn copyDockerArtifacts
inputDir = project.file('build/docker')
tag = 'javaee-docker-gradle'
}
task createContainer(type: DockerCreateContainer) {
dependsOn buildImage
targetImageId { buildImage.getImageId() }
portBindings = ['8080:8080']
}
task startContainer(type: DockerStartContainer) {
dependsOn createContainer
targetContainerId { createContainer.getContainerId() }
}