Skip to content

Commit

Permalink
fix: native build using spring-boot:build-image
Browse files Browse the repository at this point in the history
* also removed the sonar-coverage profile
  • Loading branch information
DarkAtra committed Mar 31, 2024
1 parent 10050ee commit bbca393
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
cache: maven

- name: Run Tests
run: mvn -B -ntp -Psonar-coverage verify
run: mvn -B -ntp verify

verify-native:
strategy:
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Find the latest docker image [here](https://github.com/idealo/spring-endpoint-ex
```yaml
services:
spring-endpoint-exporter:
image: ghcr.io/idealo/spring-endpoint-exporter:1.0.10
image: ghcr.io/idealo/spring-endpoint-exporter:1.0.11
mem_reservation: 256M
mem_limit: 512M
volumes:
Expand Down Expand Up @@ -57,13 +57,13 @@ You can pass properties to the application using environment variables or comman

```
export EXPORTER_INPUT_PATH=/data/app.jar
java -jar ./spring-endpoint-exporter-1.0.10.jar
java -jar ./spring-endpoint-exporter-1.0.11.jar
```

or

```
java -jar ./spring-endpoint-exporter-1.0.10.jar --exporter.input-path="/data/app.jar" --exporter.include-filters="de.idealo.*"
java -jar ./spring-endpoint-exporter-1.0.11.jar --exporter.input-path="/data/app.jar" --exporter.include-filters="de.idealo.*"
```
## Building from source
Expand All @@ -79,7 +79,7 @@ Simply run the following command:
You can now run the application using:
```
java -jar ./target/spring-endpoint-exporter-1.0.10.jar
java -jar ./target/spring-endpoint-exporter-1.0.11.jar
```
### Docker Image
Expand All @@ -90,17 +90,21 @@ Make sure your docker daemon is running and run the following command:
./mvnw clean spring-boot:build-image
```
The resulting image is named `ghcr.io/idealo/spring-endpoint-exporter:1.0.10`.
The resulting image is named `ghcr.io/idealo/spring-endpoint-exporter:1.0.11`.
### Native Docker Image (Beta)
| ⓘ Note |
|:---------------------------------------------------------------------------|
| The native image is currently only compatible with the `x86` architecture. |
Make sure your docker daemon is running and run the following command:
```
./mvnw -Pnative clean spring-boot:build-image
```
The resulting native image is named `ghcr.io/idealo/spring-endpoint-exporter:1.0.10-native`.
The resulting native image is named `ghcr.io/idealo/spring-endpoint-exporter:1.0.11-native`.
## Known limitations
Expand Down
53 changes: 9 additions & 44 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<kotlin.code.style>official</kotlin.code.style>
<kotlin.version>1.9.23</kotlin.version>
<java.version>21</java.version>
<java.version>17</java.version>

<asm.version>9.6</asm.version>
<springdoc-openapi.version>2.4.0</springdoc-openapi.version>
Expand Down Expand Up @@ -128,7 +128,7 @@
<builder>paketobuildpacks/builder-jammy-tiny:0.0.239</builder>
<env>
<BP_OCI_SOURCE>${project.scm.url}</BP_OCI_SOURCE>
<BP_JVM_VERSION>${java.version}</BP_JVM_VERSION>
<BP_JVM_VERSION>21</BP_JVM_VERSION> <!-- required so that GraalVM 21 is used -->
</env>
</image>
</configuration>
Expand All @@ -141,47 +141,6 @@
</build>

<profiles>
<profile>
<id>sonar-coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>agent-for-ut</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>agent-for-it</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
<execution>
<id>default-report-ut</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-report-it</id>
<goals>
<goal>report-integration</goal>
</goals>
</execution>
</executions>
<configuration>
<append>true</append>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>publish-ghcr</id>
<build>
Expand Down Expand Up @@ -219,11 +178,15 @@
<configuration>
<image>
<env>
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>--enable-url-protocols=jar --strict-image-heap</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>--enable-url-protocols=jar</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
</env>
</image>
</configuration>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
Expand All @@ -236,6 +199,7 @@
<artifactId>native-maven-plugin</artifactId>
<configuration>
<buildArgs combine.children="append">
<!-- Workaround for https://github.com/oracle/graal/issues/6957 -->
<arg>--strict-image-heap</arg>
</buildArgs>
</configuration>
Expand All @@ -252,6 +216,7 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<!-- Might be obsolete soon as https://github.com/paketo-buildpacks/native-image/releases/tag/v5.13.0 introduced arm support -->
<builder>dashaun/builder:tiny</builder>
</image>
</configuration>
Expand Down

0 comments on commit bbca393

Please sign in to comment.