I was following this tutorial to upload a spring boot app as a package to github registry. In this tutorial, on the bottom of the page you can see a packaging of the app in the java-native form like this:
pack build ghcr.io/jonashackt/spring-boot-flyio:latest \
--builder paketobuildpacks/builder:tiny \
--buildpack paketo-buildpacks/[email protected] \
--path . \
--env "BP_JVM_VERSION=17" \
--env "BP_NATIVE_IMAGE=true" \
--cache-image ghcr.io/jonashackt/spring-boot-flyio-paketo-cache-image:latest \
--publish
After some trial & error, I found out that paketobuildpacks/builder:tiny
is deprecated and I used paketobuildpacks/builder-jammy
. Now, my problem is that even though the package is uploaded, when I run it with docker run link/to/registry
, the spring boot app stops immediately, like this:
this is the script i ran:
pack build ghcr.io/dragosp33/hello-world-native:latest --builder paketobuildpacks/builder-jammy-tiny --buildpack paketo-buildpacks/java-native-image --path . --env "BP_JVM_VERSION=17" --env "BP_NATIVE_IMAGE=true" --publish
However, if I don't use the paketo-buildpacks/java-native-image
and resort to simple:
pack build ghcr.io/dragosp33/second-hello-world-non-native:latest --builder paketobuildpacks/builder-jammy-tiny --publish
I can go with docker run -p 8080:8080 ghcr.io/dragosp33/second-hello-world-non-native:latest
and the app starts and runs on port 8080.
Here is my spring boot application pom.xml ( is the only file that seems important, the entire app is just a hello world app )
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo44</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo44</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>paketobuildpacks/builder-jammy-tiny:latest</builder>
</image>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
What could be the problem here?