Skip to content

Commit d184202

Browse files
committed
feat: nativeCompile을 통해 스프링부트를 생성하는 기능 추가
1 parent 136260a commit d184202

File tree

14 files changed

+168
-3
lines changed

14 files changed

+168
-3
lines changed

graalvm-example/README.md

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,81 @@ Finished generating 'helloworld' in 25.3s.
116116
![img_2.png](img_2.png)
117117

118118

119-
120119
<!-- ###################################################################################################################################### -->
121120
<!-- ###################################################################################################################################### -->
122121
<!-- ###################################################################################################################################### -->
123122
<br/>
124123

125124
# Example (with spring boot)
126125

127-
nothing.
128126

127+
### gradle을 사용해서 빌드하기
128+
graalvm build tool을 추가하고, `./gradlew nativeCompile` 명령어를 사용하여 빌드가 가능함
129+
```groovy
130+
plugins {
131+
id 'org.graalvm.buildtools.native' version '0.10.2'
132+
}
133+
```
134+
135+
![img_3.png](img_3.png)
136+
137+
138+
### 빌드 결과물 위치
139+
인텔리제이 스프링부트 프로젝트 기준 `project/build/native/natvieCompile` 에 위치함
140+
141+
![img_4.png](img_4.png)
142+
143+
144+
### 실행결과
145+
61ms만에 빈 스프링 프로젝트가 실행된 모습
146+
147+
148+
![img_8.png](img_8.png)
149+
150+
![img_9.png](img_9.png)
151+
152+
# BootBuildImage
129153

154+
도커 이미지로 만들어봅시다.
130155

156+
`./gradlew bootBuildImage` 명령어를 사용합니다.
131157

158+
### 빌드 성공
159+
14분 걸린거... 이거 맞나요..? ^_^
160+
![img_6.png](img_6.png)
161+
162+
### 도커 이미지로 추가된 모습
163+
![img_7.png](img_7.png)
164+
165+
### 실행한 모습
166+
`docker run -d -p 8080:8080 --name graalvm-example-container graalvm-example:0.0.1-SNAPSHOT`
167+
168+
안켜짐 ㅠㅠ
169+
```shell
170+
171+
   ~/Documents/GitHub/SpringExample/graalvm-example/build/native    GraalVM +23 !7 ?42  docker logs -f graalvm-example-container  ✔  03:12:46 
172+
OrbStack ERROR: Dynamic loader not found: /lib64/ld-linux-x86-64.so.2
173+
174+
This usually means that you're running an x86 program on an arm64 OS without multi-arch libraries.
175+
To fix this, you can:
176+
1. Use an Intel (amd64) container to run this program; or
177+
2. Install multi-arch libraries in this container.
178+
179+
This can also be caused by running a glibc executable in a musl distro (e.g. Alpine), or vice versa.
180+
181+
For more details and instructions, see https://go.orbstack.dev/multiarch
182+
OrbStack ERROR: Dynamic loader not found: /lib64/ld-linux-x86-64.so.2
183+
184+
This usually means that you're running an x86 program on an arm64 OS without multi-arch libraries.
185+
To fix this, you can:
186+
1. Use an Intel (amd64) container to run this program; or
187+
2. Install multi-arch libraries in this container.
188+
189+
This can also be caused by running a glibc executable in a musl distro (e.g. Alpine), or vice versa.
190+
191+
For more details and instructions, see https://go.orbstack.dev/multiarch
192+
193+
```
132194

133195
<!-- ###################################################################################################################################### -->
134196
<!-- ###################################################################################################################################### -->
@@ -171,3 +233,6 @@ https://docs.spring.io/spring-boot/reference/packaging/native-image/index.html
171233

172234
https://www.baeldung.com/graal-java-jit-compiler
173235

236+
https://docs.spring.io/spring-boot/reference/packaging/native-image/introducing-graalvm-native-images.html
237+
238+
https://docs.spring.io/spring-boot/how-to/native-image/developing-your-first-application.html

graalvm-example/img_3.png

37.3 KB
Loading

graalvm-example/img_4.png

34 KB
Loading

graalvm-example/img_5.png

220 KB
Loading

graalvm-example/img_6.png

12.4 KB
Loading

graalvm-example/img_7.png

75 KB
Loading

graalvm-example/img_8.png

314 KB
Loading

graalvm-example/img_9.png

90.1 KB
Loading

graalvm-example/src/main/java/graalvm/graalvmexample/HelloWorld.class renamed to graalvm-example/src/main/java/graalvm/graalvmexample/hello/HelloWorld.class

File renamed without changes.

graalvm-example/src/main/java/graalvm/graalvmexample/HelloWorld.java renamed to graalvm-example/src/main/java/graalvm/graalvmexample/hello/HelloWorld.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//package graalvm.graalvmexample;
1+
package graalvm.graalvmexample.hello;//package graalvm.graalvmexample;
22

33
public class HelloWorld {
44
public static void main(String[] args) {

0 commit comments

Comments
 (0)