-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
168 lines (143 loc) · 4.67 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
buildscript {
repositories {
jcenter()
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.11.6"
classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
classpath "se.transmode.gradle:gradle-docker:1.2"
classpath 'com.h2database:h2:1.4.191'
}
}
plugins {
id "org.flywaydb.flyway" version "4.1.2"
}
version "0.1"
group "canoon"
apply plugin:"maven"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin:"asset-pipeline"
apply plugin:"docker"
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.1.3.Final"
compile "org.hibernate:hibernate-ehcache:5.1.3.Final"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.11.6"
runtime "com.h2database:h2"
runtime 'mysql:mysql-connector-java:5.1.36'
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
compile 'org.grails.plugins:spring-security-core:3.0.3'
compile "org.grails.plugins:spring-security-rest:2.0.0.M2"
compile 'org.ajbrown:NameMachine:0.1.1'
compile "org.flywaydb:flyway-core:4.1.2"
provided "org.springframework.boot:spring-boot-starter-tomcat"
}
bootRun {
jvmArgs('-Dspring.output.ansi.enabled=always')
addResources = true
}
jar {
baseName = 'canoon'
version = '0.1.0'
}
assets {
minifyJs = true
minifyCss = true
}
String getDockerImageName() {
"canoon-prod-api"
}
String getMysqlDockerImageName() {
"canoon-mysql-db"
}
task buildDockerImage() {
description = 'Build a docker image'
doFirst {
println ">> Creating image: ${dockerImageName}"
/* copy the generate war file to /build/docker/app */
copy {
from war.archivePath
into 'build/app/'
}
/* rename war file to application.jar */
file("build/app/${war.archiveName}").renameTo("build/app/application.jar")
}
}
task devRun(type: Exec) {
description "Running Production API container"
dependsOn buildDockerImage
commandLine 'docker', 'run', '-i', '-t', '-p', '8080:8080', '--name', 'prodapicontainer', "${dockerImageName}"
}
task buildMysqlImage(type: Exec) {
description "Build mysql docker image"
commandLine 'docker', 'build', '-f', 'build/docker/mysql/Dockerfile', '-t', "${mysqlDockerImageName}", 'build/docker/mysql'
doFirst {
println ">> Creating Mysql image: ${mysqlDockerImageName}"
/* copy artifacts from src/main/docker/mysql into the build/docker/mysql */
copy {
from 'src/main/docker/mysql/'
into 'build/docker/mysql'
}
}
}
task migrateDevelopment {
description "Running development database migration"
doFirst {
flyway {
url = 'jdbc:mysql://192.168.99.100:3306/canoon'
user = 'admin'
password = 'lionvstuna'
}
}
}
task migrateProduction {
description "Running production database migration"
doFirst {
flyway {
url = 'jdbc:mysql://if0ck476y7axojpg.cbetxkdyhwsb.us-east-1.rds.amazonaws.com:3306/psbguumu4f0sup75'
user = 'edfylo5lxbmld8ag'
password = 'j39zofnptr1n8z67'
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
task stage() {
dependsOn clean, war
}
tasks.stage.doLast() {
delete fileTree(dir: "build/distributions")
delete fileTree(dir: "build/assetCompile")
delete fileTree(dir: "build/distributions")
delete fileTree(dir: "build/libs", exclude: "*.war")
}
war.mustRunAfter clean
stage.finalizedBy migrateProduction
migrateProduction.finalizedBy flywayMigrate
migrateDevelopment.finalizedBy flywayMigrate