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
+8-9Lines changed: 8 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,19 +30,18 @@ projects: []
30
30
31
31
## Introduction
32
32
33
-
In this post, I'd like to present a few options to ship a spring boot application in a docker container. There are many easy ways to *dockerize a spring boot* (probably a nice google hit search), but I don't see too much discussion around the pros and cons. So let's jump into it
33
+
In this post, I'd like to present a few options to ship a spring boot application in a docker container. There are many ways to *dockerize a spring boot* (probably a nice google hit search), but I don't see too much discussion around the pros and cons. So let's jump into it.
34
34
35
35
## Create new project
36
36
37
-
Just go to https://start.spring.io/ and create a new project. I'll be using:
37
+
Go to https://start.spring.io/ and create a new project. I'll be using:
38
38
39
39
- Gradle - Groovy
40
40
- Spring Boot 3.4.2
41
41
- Java 21
42
42
- Dependencies: Spring Web
43
43
44
-
For demonstration, I'm going to add the "/ping" endpoint and it's going to return "pong". Just simply create `PingController.java`.
45
-
44
+
For demonstration, I'm going to add a "/ping" endpoint and it's going to return "pong". Just simply create `PingController.java`.
@@ -94,7 +93,7 @@ You can build and run the Docker image:
94
93
95
94
```sh
96
95
docker build -t dockerize-spring-boot .
97
-
docker run -it -p 8080:8080 --rm $ dockerize-spring-boot
96
+
docker run -it -p 8080:8080 --rm dockerize-spring-boot
98
97
```
99
98
100
99
Verify that we can reach our REST API within the container as expected:
@@ -110,7 +109,7 @@ Are we done? - Not at all.
110
109
111
110
Creating `Dockerfile` manually has its pros and cons. It's the most flexible solution where you control everything. No dependency needed.
112
111
113
-
The problem comes when you need more than a `Hello World` example.
112
+
But I think the biggest drawback with this approach is that **it seems** everything is working, but in fact it is hiding the underlining work that is missing. The problem comes when you need more than a `Hello World` example.
114
113
115
114
#### Repetitive
116
115
@@ -119,11 +118,11 @@ When you have more than 1 java app to dockerize, the number of dockerfiles start
119
118
#### Efficiency
120
119
121
120
In this simple example, we defined our base image and started our *fat jar*. But is that the most optimal way to build and run a spring boot (or any other java) application?
122
-
For example let's change a single file in our application and build the image again:
121
+
For example, let's change a single file in our application and build the image again:
0 commit comments