Skip to content

Commit 76bbb5b

Browse files
committed
Small changes in the first section
1 parent 434678d commit 76bbb5b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

content/post/dockerize-spring-boot.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,18 @@ projects: []
3030

3131
## Introduction
3232

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.
3434

3535
## Create new project
3636

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:
3838

3939
- Gradle - Groovy
4040
- Spring Boot 3.4.2
4141
- Java 21
4242
- Dependencies: Spring Web
4343

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`.
4645

4746
```java
4847
package com.nukesz.demo;
@@ -74,7 +73,7 @@ java -jar build/libs/dockerize-spring-boot-0.0.1-SNAPSHOT.jar
7473
Verify our REST API is working as expected:
7574

7675
```sh
77-
curl http://localhost:8080/ping
76+
$ curl http://localhost:8080/ping
7877
> Pong!
7978
```
8079

@@ -94,7 +93,7 @@ You can build and run the Docker image:
9493

9594
```sh
9695
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
9897
```
9998

10099
Verify that we can reach our REST API within the container as expected:
@@ -110,7 +109,7 @@ Are we done? - Not at all.
110109

111110
Creating `Dockerfile` manually has its pros and cons. It's the most flexible solution where you control everything. No dependency needed.
112111

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.
114113

115114
#### Repetitive
116115

@@ -119,11 +118,11 @@ When you have more than 1 java app to dockerize, the number of dockerfiles start
119118
#### Efficiency
120119

121120
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:
123122

124123
```sh
125124
# Let's measure the re-build
126-
$ time ( ./gradlew build -x test; docker build -t dockerize-spring-boot .)
125+
$ time ( ./gradlew build -x test; docker build -t dockerize-spring-boot . )
127126
> ..
128127
> => [3/3] COPY build/libs/dockerize-spring-boot-*.jar /opt/app/myapp.jar
129128
> ..

0 commit comments

Comments
 (0)