Skip to content

Commit

Permalink
Fallback to Dockerfile to generate native image
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrankel committed Oct 24, 2024
1 parent 168eeb8 commit 4986539
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#docker build -t spring-in-docker:6.5 .
FROM container-registry.oracle.com/graalvm/native-image:23 AS build

COPY .mvn .mvn
COPY mvnw .
COPY pom.xml .
COPY src src

RUN --mount=type=cache,target=/root/.m2,rw ./mvnw -Pnative native:compile -DskipTests

FROM busybox:1.37-glibc

COPY --from=build /app/target/spring-in-docker spring-in-docker

EXPOSE 8080

ENTRYPOINT ["./spring-in-docker"]
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>ch.frankel.blog</groupId>
<artifactId>spring-in-docker</artifactId>
<version>6.0</version>
<version>6.5</version>
<properties>
<java.version>21</java.version>
</properties>
Expand All @@ -27,23 +27,23 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
<image>
<name>${project.artifactId}:${project.version}</name>
<env>
<BP_JVM_VERSION>21</BP_JVM_VERSION>
</env>
</image>
</configuration>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<mainClass>ch.frankel.blog.springindocker.SpringInDockerApplication</mainClass>
<buildArgs>
<buildArg>-H:+StaticExecutableWithDynamicLibC</buildArg>
</buildArgs>
</configuration>
</plugin>
</plugins>
Expand Down

0 comments on commit 4986539

Please sign in to comment.