Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit 65df66a

Browse files
committed
Polish
See gh-736 See gh-738
1 parent 6c47093 commit 65df66a

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

spring-native-docs/src/main/asciidoc/attributes.adoc

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
:hide-uri-scheme:
66
:version: 0.10.0-SNAPSHOT
77

8+
:buildpacks: https://buildpacks.io/
9+
:buildpacks-docs: {buildpacks}/docs
10+
811
:github-tag: main
912
:github-repo: spring-projects-experimental/spring-native
1013
:github-raw: https://raw.githubusercontent.com/{github-repo}/{github-tag}
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,50 @@
11
[[executable-jar-to-native]]
22
== Executable JAR to native
33

4-
It is possible to turn a https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-executable-jar-format.html[Spring Boot executable JAR] to a native executable or a container image containing a native executable. This can be useful for various use cases:
4+
It is possible to turn a {spring-boot-docs}/html/appendix-executable-jar-format.html[Spring Boot executable JAR] to a native executable, or a container image containing a native executable.
5+
This can be useful for various use cases:
56

67
* Keep the regular JVM pipeline and turn the JVM Spring Boot application to native on the CI/CD platform.
7-
* Keep an architecture neutral deployment artifact (`native-image` https://github.com/oracle/graal/issues/407[does not support cross-compilation]).
8+
* Keep an architecture neutral deployment artifact, as `native-image` https://github.com/oracle/graal/issues/407[does not support cross-compilation].
89

910
WARNING: A mandatory pre-requisite is to use <<spring-aot>> Maven or Gradle upstream to build the Spring Boot executable JAR.
1011

1112
=== With Buildpacks
1213

13-
With Spring Boot, https://buildpacks.io/[Buildpacks] is usually used with the Maven (`mvn spring-boot:build-image`) or Gradle (`gradle bootBuilImage`) integration. But you can also use directly https://buildpacks.io/docs/tools/pack/[the `pack` CLI] to turn a Spring Boot executable JAR built with <<spring-aot>> into an optimized container image:
14+
Spring Boot applications usually use {buildpacks}[Buildpacks] via the Maven (`mvn spring-boot:build-image`), or Gradle (`gradle bootBuilImage`) integration.
15+
You can also use directly {buildpacks-docs}/tools/pack/[the `pack` CLI] to turn a Spring Boot executable JAR built with <<spring-aot>> into an optimized container image.
1416

15-
* Prerequisite: a Docker daemon needs to be available, https://hub.docker.com/search?type=edition&offering=community[locally] or https://buildpacks.io/docs/app-developer-guide/build-a-windows-app/#using-remote-docker-hosts[remotely].
16-
* https://buildpacks.io/docs/tools/pack/[Install `pack`].
17-
* Adapt to your project and run `pack build --builder paketobuildpacks/builder:tiny --path target/my-app-0.0.1-SNAPSHOT.jar --env 'BP_NATIVE_IMAGE=true' my-app:0.0.1`
17+
First, make sure that a Docker daemon is available, either https://hub.docker.com/search?type=edition&offering=community[locally] or {buildpacks-docs}/app-developer-guide/build-a-windows-app/#using-remote-docker-hosts[remotely].
18+
You also need to {buildpacks-docs}/tools/pack/[Install `pack`].
19+
20+
Assuming a Spring Boot executable JAR built as `my-app-0.0.1-SNAPSHOT.jar` in the `target` directory, run:
21+
22+
[source,bash]
23+
----
24+
pack build --builder paketobuildpacks/builder:tiny \
25+
--path target/my-app-0.0.1-SNAPSHOT.jar --env 'BP_NATIVE_IMAGE=true' my-app:0.0.1
26+
----
1827

1928
NOTE: This does not require a local `native-image` installation.
2029

2130
=== With `native-image`
2231

23-
Another option is to turn a Spring Boot executable JAR built with <<spring-aot>> into a native executable using GraalVM `native-image` compiler:
32+
Another option is to turn a Spring Boot executable JAR built with <<spring-aot>> into a native executable using the GraalVM `native-image` compiler.
33+
For this to work, you need to <<getting-started-native-image-system-requirements,Install native-image>>.
2434

25-
* <<getting-started-native-image-system-requirements,Install native-image>>.
26-
* Adapt to your project and run:
35+
Assuming a Spring Boot executable JAR built as `my-app-0.0.1-SNAPSHOT.jar` in the `target` directory:
2736

28-
```
37+
[source,bash]
38+
----
2939
#!/usr/bin/env bash
3040
3141
rm -rf target/native-image
3242
mkdir -p target/native-image
3343
cd target/native-image
34-
jar -xvf ../my-app-0.0.1-SNAPSHOT-exec.jar >/dev/null 2>&1
44+
jar -xvf ../my-app-0.0.1-SNAPSHOT.jar >/dev/null 2>&1
3545
cp -R META-INF BOOT-INF/classes
3646
native-image -H:Name=my-app -cp BOOT-INF/classes:`find BOOT-INF/lib | tr '\n' ':'`
3747
mv my-app ../
38-
```
48+
----
3949

40-
NOTE: This is documented as a simple bash script but can be adapted to whatever is suitable to you environment.
50+
NOTE: This is documented as a simple bash script but can be adapted to whatever is suitable to you environment.

0 commit comments

Comments
 (0)