-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild2.gradle
58 lines (49 loc) · 1.81 KB
/
build2.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
/*
Due to an issue with transient jars, the dev environment does not start
when cuba studio reads the dependencies from a build.gradle with the
buildUberJar task present.
As a workaround, the tasks for building the docker image (containing the uber jar)
are placed in this file.
The build.gradle file and this file are merged in github actions when building
the docker image.
*/
task buildUberJar(type: CubaUberJarBuilding) {
//logbackConfigurationFile = 'docker/image/uber-jar-logback.xml'
singleJar = true
appProperties = [
'cuba.automaticDatabaseUpdate':false,
'cuba.web.loginDialogDefaultUser':'<disabled>',
'cuba.web.loginDialogDefaultPassword':'<disabled>',
'cuba.web.productionMode':true
]
}
task copyJar(type: Copy, dependsOn: buildUberJar){
from file("$buildDir/distributions/uberJar/app.jar")
into file("$projectDir/docker/image/tmp")
}
task imgBuild(type:Exec, dependsOn: copyJar) {
def githash = getCheckedOutGitCommitHash()
def version = getVersion(true)
def shortVersion = getVersion(false)
def build_timestamp = getTimestamp()
workingDir "$projectDir/docker/image"
commandLine 'docker', 'build',
'--no-cache', '--force-rm',
'-t', "sogis/simi:$version",
'-t', "sogis/simi:$shortVersion",
'-t', "sogis/simi:latest",
'--label', "simi.created=$build_timestamp",
'--label', "simi.git_commit=$githash",
'--label', "simi.version=$version",
'-f', 'Dockerfile', '.'
}
task pushImg(type:Exec) {
commandLine 'docker', 'image', 'push', '--all-tags', "sogis/simi"
}
def getCheckedOutGitCommitHash() {
'git log -1 --pretty=%H'.execute().text.trim()
}
def getTimestamp() {
def date = new Date()
return date.format('yyyy-MM-dd HH:mm:ss')
}