From 073bdef74c4fbd054f73ccfaabb0368554082bc2 Mon Sep 17 00:00:00 2001 From: Plamen Totev Date: Sun, 19 Nov 2023 19:11:11 +0200 Subject: [PATCH] Revert "Revert "Use native image for the backend"" This reverts commit 05191a4966060a70df90f8ec6ea567ade9217a99. --- backend/Dockerfile | 14 +++++++++----- backend/build.gradle.kts | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 27b7610..be11807 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,11 +1,15 @@ -FROM eclipse-temurin:17-jdk AS builder +#TODO Find a better way to build the native image +FROM ubuntu:22.04 AS builder ADD ./gradle gradle ADD ./src src ADD ./gradlew gradlew ADD ./build.gradle.kts build.gradle.kts ADD ./settings.gradle.kts settings.gradle.kts -RUN ./gradlew build +RUN apt update && apt -y install build-essential libz-dev zlib1g-dev wget +RUN wget -q https://download.oracle.com/graalvm/17/latest/graalvm-jdk-17_linux-x64_bin.tar.gz +RUN tar xf graalvm-jdk-17_linux-x64_bin.tar.gz +RUN export JAVA_HOME=/graalvm-jdk-17.0.9+11.1/;./gradlew nativeCompile -FROM eclipse-temurin:17-jdk -COPY --from=builder build/libs/carboncritters-0.0.1-SNAPSHOT.jar app.jar -ENTRYPOINT ["java","-jar","/app.jar"] +FROM ubuntu:22.04 +COPY --from=builder build/native/nativeCompile/carboncritters carboncritters +ENTRYPOINT ["./carboncritters"] diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index 6fa12a5..1c7fbe5 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -2,6 +2,7 @@ plugins { java id("org.springframework.boot") version "3.1.5" id("io.spring.dependency-management") version "1.1.3" + id("org.graalvm.buildtools.native") version "0.9.28" } group = "mosquitobytes" @@ -16,7 +17,7 @@ repositories { } dependencies { - implementation(platform("com.google.cloud:spring-cloud-gcp-dependencies:4.8.0")) + implementation(platform("com.google.cloud:spring-cloud-gcp-dependencies:4.8.4")) // implementation("org.springframework.boot:spring-boot-starter-security") implementation("org.springframework.boot:spring-boot-starter-web")