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: post/index.xml
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rssversion="2.0"xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts | Norbert Benczúr</title><link>https://nukesz.github.io/post/</link><atom:linkhref="https://nukesz.github.io/post/index.xml"rel="self"type="application/rss+xml"/><description>Posts</description><generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><copyright>2025</copyright><lastBuildDate>Mon, 10 Feb 2025 20:53:53 +0100</lastBuildDate><image><url>https://nukesz.github.io/img/icon-192.png</url><title>Posts</title><link>https://nukesz.github.io/post/</link></image><item><title>Dockerize a Spring Boot application</title><link>https://nukesz.github.io/post/dockerize-spring-boot/</link><pubDate>Mon, 10 Feb 2025 20:53:53 +0100</pubDate><guid>https://nukesz.github.io/post/dockerize-spring-boot/</guid><description><h2 id="introduction">Introduction</h2>
2
-
<p>In this post, I&rsquo;d like to present a few options to ship a spring boot application in a docker container. There are many easy ways to <em>dockerize a spring boot</em> (probably a nice google hit search), but I don&rsquo;t see too much discussion around the pros and cons. So let&rsquo;s jump into it</p>
2
+
<p>In this post, I&rsquo;d like to present a few options to ship a spring boot application in a docker container. There are many ways to <em>dockerize a spring boot</em> (probably a nice google hit search), but I don&rsquo;t see too much discussion around the pros and cons. So let&rsquo;s jump into it.</p>
3
3
<h2 id="create-new-project">Create new project</h2>
4
-
<p>Just go to <a href="https://start.spring.io/">https://start.spring.io/</a> and create a new project. I&rsquo;ll be using:</p>
4
+
<p>Go to <a href="https://start.spring.io/">https://start.spring.io/</a> and create a new project. I&rsquo;ll be using:</p>
5
5
<ul>
6
6
<li>Gradle - Groovy</li>
7
7
<li>Spring Boot 3.4.2</li>
8
8
<li>Java 21</li>
9
9
<li>Dependencies: Spring Web</li>
10
10
</ul>
11
-
<p>For demonstration, I&rsquo;m going to add the&ldquo;/ping&rdquo; endpoint and it&rsquo;s going to return &ldquo;pong&rdquo;. Just simply create <code>PingController.java</code>.</p>
11
+
<p>For demonstration, I&rsquo;m going to add a&ldquo;/ping&rdquo; endpoint and it&rsquo;s going to return &ldquo;pong&rdquo;. Just simply create <code>PingController.java</code>.</p>
<p>The jar is actually created with the <code>bootJar</code> task. You can learn more about it in the <a href="https://docs.spring.io/spring-boot/docs/2.5.1/gradle-plugin/reference/htmlsingle/#packaging-executable.and-plain-archives">spring doc</a></p>
29
29
</blockquote>
30
30
<p>Verify our REST API is working as expected:</p>
</code></pre></div><p>Are we done? - Not at all.</p>
47
47
<h3 id="whats-the-problem">What&rsquo;s the problem?</h3>
48
48
<p>Creating <code>Dockerfile</code> manually has its pros and cons. It&rsquo;s the most flexible solution where you control everything. No dependency needed.</p>
49
-
<p>The problem comes when you need more than a <code>Hello World</code> example.</p>
49
+
<p>But I think the biggest drawback with this approach is that <strong>it seems</strong> everything is working, but in fact it is hiding the underlining work that is missing. The problem comes when you need more than a <code>Hello World</code> example.</p>
50
50
<h4 id="repetitive">Repetitive</h4>
51
51
<p>When you have more than 1 java app to dockerize, the number of dockerfiles starts to grow and you have to maintain and update each file independently.</p>
52
52
<h4 id="efficiency">Efficiency</h4>
53
53
<p>In this simple example, we defined our base image and started our <em>fat jar</em>. But is that the most optimal way to build and run a spring boot (or any other java) application?
54
-
For example let&rsquo;s change a single file in our application and build the image again:</p>
54
+
For example, let&rsquo;s change a single file in our application and build the image again:</p>
55
55
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh"><span style="color:#75715e"># Let&#39;s measure the re-build</span>
<span><iclass="fas fa-bars"></i></span></button><divclass="collapse navbar-collapse" id=navbar><ulclass="navbar-nav mr-auto"><liclass=nav-item><aclass=nav-linkhref=/#about><span>Home</span></a></li><liclass=nav-item><aclass=nav-linkhref=/#posts><span>Posts</span></a></li></ul><ulclass="navbar-nav ml-auto"><liclass=nav-item><aclass="nav-link js-search" href=#><iclass="fas fa-search" aria-hidden=true></i></a></li><liclass=nav-item><aclass="nav-link js-dark-toggle" href=#><iclass="fas fa-moon" aria-hidden=true></i></a></li></ul></div></div></nav><divclass="universal-wrapper pt-3"><h1>docker</h1></div><divclass=universal-wrapper><div><h2><ahref=/post/dockerize-spring-boot/>Dockerize a Spring Boot application</a></h2><divclass=article-style>Introduction 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
4
-
Create new project Just go to https://start.spring.io/ and create a new project. I’ll be using:
3
+
<span><iclass="fas fa-bars"></i></span></button><divclass="collapse navbar-collapse" id=navbar><ulclass="navbar-nav mr-auto"><liclass=nav-item><aclass=nav-linkhref=/#about><span>Home</span></a></li><liclass=nav-item><aclass=nav-linkhref=/#posts><span>Posts</span></a></li></ul><ulclass="navbar-nav ml-auto"><liclass=nav-item><aclass="nav-link js-search" href=#><iclass="fas fa-search" aria-hidden=true></i></a></li><liclass=nav-item><aclass="nav-link js-dark-toggle" href=#><iclass="fas fa-moon" aria-hidden=true></i></a></li></ul></div></div></nav><divclass="universal-wrapper pt-3"><h1>docker</h1></div><divclass=universal-wrapper><div><h2><ahref=/post/dockerize-spring-boot/>Dockerize a Spring Boot application</a></h2><divclass=article-style>Introduction 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.
4
+
Create new project Go to https://start.spring.io/ and create a new project. I’ll be using:
0 commit comments