-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.gradle
155 lines (134 loc) · 4.37 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE")
classpath('se.transmode.gradle:gradle-docker:1.2')
}
}
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'docker'
jar {
baseName = 'spring-boot-app'
version = '0.1.0'
}
project.ext.gcp = "gcr.io/cloudjlb-eventer"
class SimpleDockerBuild extends Exec {
String tag;
public SimpleDockerBuild() {
super()
executable = "docker"
}
void setTag(String t) {
tag = t;
args = ["build", "-t", tag, "."]
}
}
task buildBootImage(type: SimpleDockerBuild) {
tag = "${project.ext.gcp}/${jar.baseName}"
workingDir = "."
}
task deployBootImage(type: Exec, dependsOn: buildBootImage) {
commandLine "gcloud","docker","--","push", "${buildBootImage.tag}"
}
task npmInstall(type: Exec) {
workingDir "web-frontend/eventer"
commandLine "npm", "install", "."
}
task buildAngular(type: Exec, dependsOn: npmInstall) {
workingDir "web-frontend/eventer"
commandLine "ng", "build"
}
task buildFeImage(type: SimpleDockerBuild) {
tag = "${project.ext.gcp}/web-frontend"
workingDir = "web-frontend"
}
task deployFeImage(type: Exec, dependsOn: buildFeImage) {
commandLine "gcloud", "docker", "--", "push", "${buildFeImage.tag}"
}
task buildRedisImage(type: SimpleDockerBuild) {
tag = "${project.ext.gcp}/redis-sentinel"
workingDir = "kubernetes/images/redis"
}
task deployRedisImage(type: Exec, dependsOn: buildRedisImage) {
commandLine "gcloud", "docker", "--", "push", "${buildRedisImage.tag}"
}
def gcpFilter = { String line -> line.replaceAll("#GCP", project.ext.gcp) }
task buildKubs << {
copy {
from 'kubernetes/redis'
into 'kubernetes-build/redis'
filter gcpFilter
}
copy {
from 'kubernetes/app'
into 'kubernetes-build/app'
filter gcpFilter
}
copy {
from 'kubernetes/frontend'
into 'kubernetes-build/frontend'
filter gcpFilter
}
}
task deployToGKE(type: DefaultTask, dependsOn: buildKubs) {
def kubectl = ["kubectl", "create", "-f"]
def buildDir = "kubernetes-build"
doLast {
exec {
workingDir buildDir
commandLine kubectl + "redis/"
}
exec {
workingDir buildDir
commandLine kubectl + "app/"
}
exec {
workingDir buildDir
commandLine kubectl + "frontend/"
}
exec {
commandLine kubectl + "kubernetes/load-balancer/"
}
}
}
task deleteFromGKE << {
def kubedel = ["kubectl", "delete"]
exec { commandLine kubedel + ["service", "redis-master"] }
exec { commandLine kubedel + ["service", "redis-sentinel"] }
exec { commandLine kubedel + ["service", "redis-slave"] }
exec { commandLine kubedel + ["statefulset", "redis-slave"] }
exec { commandLine kubedel + ["statefulset", "redis-sentinel"] }
exec { commandLine kubedel + ["statefulset", "redis-master"] }
exec { commandLine kubedel + ["deployment", "spring-boot"] }
exec { commandLine kubedel + ["deployment", "frontend"] }
exec { commandLine kubedel + ["service", "frontend"] }
exec { commandLine kubedel + ["service", "api"] }
exec { commandLine kubedel + ["pvc", "redis-data-claim"]}
// exec { commandLine kubedel + ["service", "redis-replication"] }
exec { commandLine kubedel + ["ing", "boot"] }
exec { commandLine kubedel + ["secret", "self-signed-cert"] }
}
repositories {
mavenCentral()
}
targetCompatibility = 1.8
sourceCompatibility = 1.8
dependencies {
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.data:spring-data-redis"
compile "biz.paluch.redis:lettuce:3.5.0.Final"
compile "se.transmode.gradle:gradle-docker:1.2"
//compile "org.springframework.boot:spring-boot-starter-security"
//compile "com.google.firebase:firebase-admin:4.0.3"
compile group: 'com.google.cloud', name: 'google-cloud-datastore', version: '0.8.0-beta'
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile group: 'junit', name: 'junit', version: '4.11'
}