You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.adoc
+49-9Lines changed: 49 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ Learn how to containerize, package, and run a Spring Boot application on Open Li
29
29
30
30
== What you'll learn
31
31
32
-
The starting point of this guide is the finished application from the https://spring.io/guides/gs/spring-boot/[Building an Application with Spring Boot^] guide. If you are not familiar with Spring Boot, complete that guide first. Java 17 is required to run this project.
32
+
The starting point of this guide is the finished application from the https://spring.io/guides/gs/spring-boot/[Building an Application with Spring Boot^] guide. If you are not familiar with Spring Boot, complete that guide first. Java 21 is required to run this project.
33
33
34
34
You will learn how to use the `springBootUtility` command to deploy a Spring Boot application in Docker on Open Liberty without modification. This command stores the dependent library JAR files of the application to the target library cache, and packages the remaining application artifacts into a thin application JAR file.
35
35
@@ -124,7 +124,7 @@ Navigate to the `start` directory.
124
124
----
125
125
126
126
Dockerfile
127
-
[source, Text, linenums, role='code_column']
127
+
[source, Text, linenums, role='code_column']
128
128
----
129
129
include::finish/Dockerfile[]
130
130
----
@@ -155,7 +155,7 @@ Your `springboot` image appears in the list of Docker images:
155
155
[role='no_copy']
156
156
```
157
157
REPOSITORY TAG IMAGE ID CREATED SIZE
158
-
springboot latest 3a5492c0cbeb 27 seconds ago 789MB
158
+
springboot latest 3a5492c0cbeb 27 seconds ago 485MB
159
159
```
160
160
161
161
Now, you can run the Spring Boot application in a Docker container:
@@ -175,7 +175,7 @@ You see an entry similar to the following example:
175
175
[role='no_copy']
176
176
----
177
177
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
178
-
e33532aa07d6 springboot "/opt/ibm/docker/doc…" 7 seconds ago Up 2 seconds 0.0.0.0:9080->9080/tcp, 0.0.0.0:9443->9443/tcp springBootContainer
178
+
e33532aa07d6 springboot "/opt/ol/helpers/run…" 7 seconds ago Up 2 seconds 0.0.0.0:9080->9080/tcp, 0.0.0.0:9443->9443/tcp springBootContainer
179
179
----
180
180
181
181
You can watch the application start by monitoring the logs:
Wait for the following message, which indicates that Liberty’s startup is complete in several seconds:
188
188
[role='no_copy']
189
189
----
190
+
...
191
+
CWWKZ0001I: Application thin-guide-spring-boot-0.1.0 started in 5.542 seconds.
192
+
...
190
193
CWWKF0011I: The defaultServer server is ready to run a smarter planet.
191
194
The defaultServer server started in 7.121 seconds.
192
195
----
@@ -224,7 +227,35 @@ If you are working on a Linux system with kernel version 5.9 or greater, you can
224
227
uname -r
225
228
```
226
229
227
-
You have built the `springboot` container image in the previous section. To take a checkpoint of the application process with the `afterAppStart` option, run the following command:
230
+
The https://openliberty.io/docs/latest/reference/feature/crac.html[Coordinated Restore at Checkpoint^] feature enables Liberty to use the Liberty’s implementation of https://javadoc.io/doc/org.crac/crac/1.4.0/index.html[org.crac^] APIs and more logs from Spring when the application is restoring.
Copy the provided [hotspot=cracXml file=0]`crac.xml` configuration file to the Liberty `configDropins` configuration directory. The crac.xml file enables the [hotspot=crac file=1]`crac` feature to the Liberty instance.
251
+
252
+
Run the following command to rebuild the Docker image:
253
+
[role='command']
254
+
```
255
+
docker build -t springboot .
256
+
```
257
+
258
+
To take a checkpoint of the application process with the `afterAppStart` option, run the following command:
228
259
229
260
[role='command']
230
261
```
@@ -256,9 +287,9 @@ Your `springboot-instanton` image appears in the list of Docker images. It shows
256
287
257
288
[role='no_copy']
258
289
```
259
-
REPOSITORY TAG IMAGE ID CREATED SIZE
260
-
springboot-instanton latest c4aabcdd64bf 20 seconds ago 879MB
261
-
springboot latest 3a5492c0cbeb 14 minutes ago 789MB
290
+
REPOSITORY TAG IMAGE ID CREATED SIZE
291
+
springboot-instanton latest c4aabcdd64bf 20 seconds ago 577MB
292
+
springboot latest 3a5492c0cbeb 14 minutes ago 485MB
262
293
```
263
294
264
295
Run the `springboot-instanton` InstantOn application image by the following command:
@@ -282,10 +313,17 @@ Run the following command to see the container logs:
282
313
docker logs springBootContainer
283
314
```
284
315
285
-
Liberty’s startup is complete in less than a second:
316
+
You see more logs from Spring for restoring. Liberty’s startup is complete in less than a second:
286
317
287
318
[role='no_copy']
288
319
----
320
+
2024-11-22T16:33:43.349Z INFO 1027 --- [ecutor-thread-1] o.s.c.support.DefaultLifecycleProcessor : Restarting Spring-managed lifecycle beans after JVM restore
321
+
...
322
+
2024-11-22T16:33:43.562Z INFO 1027 --- [ecutor-thread-1] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 135784 ms
323
+
2024-11-22T16:33:43.568Z INFO 1027 --- [ecutor-thread-1] o.s.c.support.DefaultLifecycleProcessor : Spring-managed lifecycle restart completed (restored JVM running for 525 ms)
324
+
...
325
+
CWWKZ0001I: Application thin-guide-spring-boot-0.1.0 started in 0.585 seconds.
326
+
...
289
327
CWWKF0011I: The defaultServer server is ready to run a smarter planet.
290
328
The defaultServer server started in 0.323 seconds.
291
329
----
@@ -299,6 +337,8 @@ After you are finished checking out the application, stop your container by runn
299
337
docker stop springBootContainer
300
338
```
301
339
340
+
If you use Podman instead of Docker, you can build your InstantOn image in a simply way. Read the https://openliberty.io/docs/latest/instanton.html#checkpoint_script[Building the InstantOn image with Podman and the checkpoint.sh script^] documentation.
341
+
302
342
To learn more about the Liberty InstantOn feature, see the https://openliberty.io/docs/latest/instanton.html[Faster startup for containerized applications with Open Liberty InstantOn^] documentation.
0 commit comments