From f583b89f293856dc09de6e978674df27fc7d1854 Mon Sep 17 00:00:00 2001 From: Tim Yates Date: Tue, 17 Sep 2024 12:44:10 +0100 Subject: [PATCH] Test AOT to see if it speeds things up --- .../workflows/gradle-build-native-feature.yml | 2 +- .../gradle-deploy-native-develop.yml | 2 +- server/build.gradle | 23 +++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle-build-native-feature.yml b/.github/workflows/gradle-build-native-feature.yml index 142b0cf4f..ff064045e 100644 --- a/.github/workflows/gradle-build-native-feature.yml +++ b/.github/workflows/gradle-build-native-feature.yml @@ -41,4 +41,4 @@ jobs: - name: Build a native docker image uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 with: - arguments: dockerBuildNative + arguments: optimizedDockerBuildNative diff --git a/.github/workflows/gradle-deploy-native-develop.yml b/.github/workflows/gradle-deploy-native-develop.yml index d58a54294..ce6ba6294 100644 --- a/.github/workflows/gradle-deploy-native-develop.yml +++ b/.github/workflows/gradle-deploy-native-develop.yml @@ -56,7 +56,7 @@ jobs: run: |- gcloud --quiet auth configure-docker - name: Build a native docker image - run: ./gradlew dockerBuildNative + run: ./gradlew optimizedDockerBuildNative env: VITE_APP_API_URL: https://checkins-develop-native-832140020593.us-central1.run.app - name: Push the Docker image to Google Container Registry diff --git a/server/build.gradle b/server/build.gradle index 4fe79b522..834926592 100755 --- a/server/build.gradle +++ b/server/build.gradle @@ -4,6 +4,7 @@ plugins { id 'maven-publish' id("com.github.johnrengelman.shadow") version "8.1.1" id("io.micronaut.application") version "4.4.0" + id("io.micronaut.aot") version "4.4.0" id "jacoco" id("org.openrewrite.rewrite") version "latest.release" } @@ -26,6 +27,20 @@ micronaut { incremental(true) annotations("com.objectcomputing.checkins.*") } + aot { + // Please review carefully the optimizations enabled below + // Check https://micronaut-projects.github.io/micronaut-aot/latest/guide/ for more details + optimizeServiceLoading = false + convertYamlToJava = false + precomputeOperations = true + cacheEnvironment = true + optimizeClassLoading = true + deduceEnvironment = true + optimizeNetty = true + replaceLogbackXml = true + configurationProperties.put("micronaut.security.jwks.enabled","false") + configurationProperties.put("micronaut.security.openid-configuration.enabled","false") + } } dockerBuildNative { @@ -36,6 +51,14 @@ dockerBuildNative { images = ["checkins:latest"] + imageNameFromGithub } +optimizedDockerBuildNative { + def imageNameFromGithub = [] + if (System.getenv('PROJECT_ID') != null && System.getenv('SERVICE_NAME') && System.getenv('GITHUB_SHA')) { + imageNameFromGithub = ["gcr.io/${System.getenv('PROJECT_ID')}/${System.getenv('SERVICE_NAME')}:${System.getenv("GITHUB_SHA")}".toString()] + } + images = ["checkins:latest"] + imageNameFromGithub +} + graalvmNative { toolchainDetection = false binaries {