-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
104 lines (87 loc) · 3 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
buildscript {
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/plugins-release' }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
}
}
plugins {
id 'idea'
id 'com.bmuschko.docker-remote-api' version '9.3.1'
id 'com.bmuschko.docker-java-application' version '9.3.1'
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.springframework.boot'
apply plugin: 'com.bmuschko.docker-remote-api'
apply plugin: 'com.bmuschko.docker-java-application'
//*************************************************************************
// IDEA
//*************************************************************************
apply plugin: 'idea'
idea {
module {
inheritOutputDirs = true
downloadSources = true
}
}
//*************************************************************************
// Project Config
//*************************************************************************
group = 'org.laxture'
version = "${geoip2Version}"
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
tasks.withType(AbstractCompile) {
options.encoding = 'UTF-8'
}
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
}
mainClassName = 'org.laxture.geoip2.GeoIp2Application'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation "com.maxmind.geoip2:geoip2:${geoip2Version}"
}
dependencyManagement {
imports {
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
}
}
def dockerTagVersioned = "${project.name}:${version}"
def dockerTagLatest = "${project.name}:latest"
def dockerTags = [dockerTagVersioned, dockerTagLatest]
docker {
javaApplication {
baseImage = 'openjdk:17.0.2-slim'
images = dockerTags
ports = [Integer.valueOf(port)]
maintainer = 'Hank_CP "[email protected]"'
}
}
dockerCreateDockerfile {
addFile 'https://github.com/maxmind/geoipupdate/releases/download/v6.1.0/geoipupdate_6.1.0_linux_amd64.deb', '/opt/geoipupdate_6.1.0.deb'
runCommand 'apt-get update && apt-get install -y cron curl'
runCommand 'dpkg -i /opt/geoipupdate_6.1.0.deb'
runCommand provider({
return 'touch app.sh && echo "#!/bin/bash" >> app.sh && echo "/opt/update-database.sh" >> app.sh && echo "java \\$JAVA_OPT -cp /app/resources:/app/classes:/app/libs/* ' + mainClassName + '" >> app.sh && chmod +x app.sh'
})
runCommand 'echo "44 23 * * 6,3 /opt/update-database.sh" > /etc/cron.d/update-geo-ip'
runCommand 'chmod 0644 /etc/cron.d/update-geo-ip'
runCommand 'crontab /etc/cron.d/update-geo-ip'
addFile 'https://raw.githubusercontent.com/hank-cp/geoip2-docker/main/docker/update-database.sh', '/opt/update-database.sh'
runCommand 'chmod a+x /opt/update-database.sh'
entryPoint ''
workingDir '/app'
defaultCommand '/app/app.sh'
}
dockerSyncBuildContext {
duplicatesStrategy DuplicatesStrategy.INCLUDE
}