-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
95 lines (77 loc) · 2.7 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
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:3.0.11'
}
}
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'com.bmuschko.docker-remote-api'
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.DockerPushImage
repositories {
mavenCentral()
}
task copyDistWebapp(type: Copy) {
from('src/main/webapp')
into('build/distributions/rest-o-rant-web')
}
build.dependsOn copyDistWebapp
dependencies {
compile group: 'commons-io', name: 'commons-io', version: '1.4'
compile group: 'log4j', name: 'log4j', version: '1.2.15', ext: 'jar'
}
docker {
url = System.properties['docker.client.url']
if (System.properties['docker.native'] == "false") {
certPath=new File(System.properties['docker.cert.path'])
}
if (System.properties['docker.remote_registry'] == "true") {
registryCredentials {
url = System.properties['docker.registry.url']
username = System.properties['docker.registry.username']
password = System.properties['docker.registry.password']
email = System.properties['docker.registry.email']
}
}
}
task copyWebapp(type: Copy) {
from('src/main/webapp')
into('build/docker/webapp')
}
task copyNginx(type: Copy) {
from('src/main/nginx')
into('build/docker/nginx')
}
task createDockerfile(type: Dockerfile) {
dependsOn copyWebapp, copyNginx
destFile = project.file('build/docker/Dockerfile')
from 'nginx'
maintainer 'Vincent Partington <vpartington@xebialabs.com>'
environmentVariable('API_ENDPOINT','http://rest-o-rant-api:8080/rest-o-rant-api')
environmentVariable('NGINX_LISTEN','80')
copyFile('webapp', '/usr/share/nginx/html')
copyFile('nginx', '/etc/nginx/conf.d')
addFile('https://github.com/kreuzwerker/envplate/releases/download/v0.0.8/ep-linux', '/usr/local/bin/ep')
runCommand('chmod +x /usr/local/bin/ep && chmod -R 777 /etc/nginx/conf.d && mkdir -p /var/cache/nginx && mkdir -p /var/run && chmod -R 777 /var/cache/nginx /var/run')
instruction('CMD ["/usr/local/bin/ep", "-v", "/etc/nginx/conf.d/*.conf", "--", "/usr/sbin/nginx", "-g", "daemon off;"]')
}
task buildDockerImage(type: DockerBuildImage) {
dependsOn createDockerfile
inputDir = createDockerfile.destFile.parentFile
tag = System.properties['docker.repository']+"/rest-o-rant-web:$version"
}
task pushDockerImage(type: DockerPushImage) {
dependsOn buildDockerImage
imageName = System.properties['docker.repository']+"/rest-o-rant-web"
}
task wrapper(type: Wrapper) {
gradleVersion = '2.11'
}
httpPort = 8080
stopPort = 9451
stopKey = 'stop-rest-o-rant-web'