-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
72 lines (57 loc) · 2.18 KB
/
build.gradle
File metadata and controls
72 lines (57 loc) · 2.18 KB
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
plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
id("io.micronaut.application") version "3.7.10"
id 'com.google.cloud.tools.jib' version '3.4.0'
}
group = "com.example"
ext {
imagePath = "gcr.io/${gcpProjectName}/${applicationName}:${version}"
}
repositories {
mavenCentral()
}
dependencies {
annotationProcessor("io.micronaut:micronaut-http-validation")
implementation("io.micronaut:micronaut-http-client")
implementation("jakarta.annotation:jakarta.annotation-api")
implementation("io.micronaut:micronaut-inject:3.10.1")
}
application {
mainClass.set("com.example.Application")
}
shadowJar {
mergeServiceFiles()
}
graalvmNative.toolchainDetection = false
micronaut {
runtime("netty")
testRuntime("junit5")
processing {
incremental(true)
annotations("com.example.*")
}
}
task runDocker(type: Exec) {
dependsOn 'jibDockerBuild'
// GCP variant that'll use an image published (and public) on the Google Container Registry
//commandLine 'docker', 'run', '--env', 'MICRONAUT_ENVIRONMENTS=dev', '-p', '8080:8080', "gcr.io/$gcpProjectName/$applicationName:$version"
// Local variant
commandLine 'docker', 'run', '--env', 'MICRONAUT_ENVIRONMENTS=dev', '-p', '8080:8080', "$applicationName:$version"
}
// If needed - can adjust the origin image and set a target location for automated publishing
jib {
//from.image = 'adoptopenjdk:11-jre-hotspot'
// This needs auth via `gcloud auth configure-docker` locally or something else in CI
to.image = "$imagePath"
// `./gradlew jib` will then both build and publish the image
// TODO: Nexus publishing target variant URL & auth
// Interesting part will be templates with _dynamic_ pick of container registry based on Venue setup
}
// Does text manipulation to prepare k8s YAML files for deployment - should happen in a CD style context with no Git updates
task prepareCD(type: Exec) {
//NOTE: On MacOS you need -i '' 's| ... specifically, may have to remove the '' for Linux
commandLine 'bash', '-c', """
sed -i 's|APP_URL|${appUrl}|g' k8s/ingress.yaml &&
sed -i 's|IMAGE_PATH|${imagePath}|g' k8s/statefulset.yaml
"""
}