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: content/post/dockerize-spring-boot.md
+38-4Lines changed: 38 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -144,7 +144,7 @@ Many of the problems that I mentioned previously comes from that the fact that w
144
144
145
145
We can use paketo by executing the following gradle (or maven) task:
146
146
147
-
```gradle
147
+
```sh
148
148
./gradlew bootBuildImage
149
149
```
150
150
@@ -212,8 +212,8 @@ BUILD SUCCESSFUL in 1m 57s
212
212
Let's run and test our the newly created images as before:
213
213
214
214
```sh
215
-
$ docker run -it -p 8080:8080 --rm dockerize-spring-boot:0.0.1-SNAPSHOT
216
-
$ curl http://localhost:8080/ping
215
+
$ docker run -it -p 8081:8080 --rm dockerize-spring-boot:0.0.1-SNAPSHOT
216
+
$ curl http://localhost:8081/ping
217
217
> Pong!
218
218
```
219
219
@@ -226,4 +226,38 @@ For more information please have a look on the Spring doc [Packaging OCI Images]
226
226
227
227
### Jib
228
228
229
-
*Coming soon...*
229
+
Another option that I would like to present is called [Jib](https://github.com/GoogleContainerTools/jib). This is part of Google's container tools to dockerize Java applications, similar what we have seen in the previous chapter.
230
+
231
+
Let's use it via the [gradle plugin](https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin). You can add the plugin to the `build.gradle` file:
$ docker run -it -p 8082:8080 --rm dockerize-spring-boot-jib:latest
249
+
$ curl http://localhost:8082/ping
250
+
> Pong!
251
+
```
252
+
253
+
It's a very rich plugin, so I recommend to spend time how to configure it (for example how to change the base image).
254
+
255
+
### What's the catch?
256
+
257
+
The major drawback with these options is that it introduces a dependency to you project (or even a plugin). You have to learn, understand, configure and maintain it. Contributors to (open source) projects can come and go, and there is no guarantee that these project will stay and get updates forever.
258
+
259
+
This problem is not unique to these plugins, but general for all dependencies, libraries and frameworks that your projects relies on, so make sure that you evaluate before adding it to your project.
260
+
261
+
## Summary
262
+
263
+
I hope following this post you gained the knowledge how to dockerize a spring boot application and made it clear that there are always tradeoffs to consider when deciding how to create a docker image based on your application.
0 commit comments