-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update backend Dockerfile to use GraalVM img
- Loading branch information
Cesare De Cal
committed
Jul 13, 2024
1 parent
ed6690a
commit 0b2aa07
Showing
1 changed file
with
34 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
FROM openjdk:17-jdk-alpine | ||
|
||
WORKDIR /backend-app | ||
|
||
# Copy the build.gradle, settings.gradle, and gradle.properties files first | ||
# This step helps leverage Docker's caching mechanism | ||
COPY build.gradle settings.gradle gradle.properties ./ | ||
|
||
COPY gradlew ./ | ||
COPY gradle ./gradle | ||
|
||
RUN ./gradlew dependencies --no-daemon | ||
|
||
COPY . . | ||
|
||
RUN ./gradlew build --no-daemon | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["java", "-jar", "build/libs/wookieepedia-0.1-all.jar"] | ||
# Stage 1: Build the native executable using GraalVM | ||
FROM ghcr.io/graalvm/native-image:latest as build | ||
|
||
WORKDIR /backend-app | ||
|
||
# Copy the build.gradle, settings.gradle, and gradle.properties files first | ||
# This step helps leverage Docker's caching mechanism | ||
COPY build.gradle settings.gradle gradle.properties ./ | ||
|
||
COPY gradlew ./ | ||
COPY gradle ./gradle | ||
|
||
RUN ./gradlew dependencies --no-daemon | ||
|
||
COPY . . | ||
|
||
RUN ./gradlew build --no-daemon | ||
|
||
# Create the native image | ||
RUN native-image --no-fallback -H:Name=wookieepedia -cp build/libs/wookieepedia-0.1-all.jar | ||
|
||
# Stage 2: Create the final lightweight image | ||
FROM debian:buster-slim | ||
|
||
WORKDIR /backend-app | ||
|
||
# Copy the native executable from the build stage | ||
COPY --from=build /backend-app/wookieepedia /backend-app/wookieepedia | ||
|
||
# Expose the application port | ||
EXPOSE 8080 | ||
|
||
# Set the entry point to the native executable | ||
ENTRYPOINT ["/backend-app/wookieepedia"] |