close

This Week in Spring - February 11th, 2020

Hi, Spring fans! Welcome to yet another installment of This Week in Spring! It’s been a very nice week indeed. I’ve been knee-deep in finishing my book, writing more code to support the A Bootiful Podcast production pipeline, and meeting amazing people in the new VMWare organization, and beyond. I’ve also been working on some new Spring Tips videos - what would you like to see covered, my friends?

We’ve got a lot of good stuff this week, so let’s get to it!

Read more

This Week in Spring - February 4th, 2020

Hi, Spring fans! Welcome to another installment of This Week in Spring! I just finished spending a wonderful afternoon with customers and now I’m pouring through all the wonderful new content for this week. As usual, we’ve got a lot to cover so let’s get to it!

Read more

This Week in Spring - January 28th, 2020

Hi, Spring fans! How’re things, my friends? Can you believe we’re already nearly at the end of January? I have been knee-deep in code and coffee for these last several days and I’m running late for a meeting so, without further ado, let’s get to it!

Read more

Creating Docker images with Spring Boot 2.3.0.M1

Spring Boot 2.3.0.M1 has just been released and it brings with it some interesting new features that can help you package up your Spring Boot application into Docker images. In this blog post we’ll take a look at the typical ways developers create Docker images, and show how they can be improved by using these new features.

Common Docker Techniques

Although it’s always been possible to convert the fat jars produced by Spring Boot into Docker images, it’s pretty easy to make less than optimal results. If you do a web search for "dockerize spring boot app", the chances are high you’ll find an article or blog post suggesting you create a dockerfile that looks something like this:

FROM openjdk:8-jdk-alpine
EXPOSE 8080
ARG JAR_FILE=target/my-application.jar
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

Whilst this approach works fine, and it’s nice and concise, there are a few things that are sub-optimal.

The first problem with above file is that the jar file is not unpacked. There’s always a certain amount of overhead when running a fat jar, and in a containerized environment this can be noticeable. It’s generally best to unpack your jar and run in an exploded form.

The second issue with the file is that it isn’t very efficient if you frequently update your application. Docker images are built in layers, and in this case your application and all its dependencies are put into a single layer. Since you probably recompile your code more often than you upgrade the version of Spring Boot you use, it’s often better to separate things a bit more. If you put jar files in the layer before your application classes, Docker often only needs to change the very bottom layer and can pick others up from its cache.

Two new features are introduced in Spring Boot 2.3.0.M1 to help improve on these existing techniques: buildpack support and layered jars.

Read more

This Week in Spring - January 21st, 2020

Hi, Spring fans! It’s 6 am Tuesday, January 21st, 2020, and I’m buckled in and ready to take off for Atlanta, Georgia (by way of Denver, Colorado…), where I’ll be speaking at the Atlanta Java User Group tonight! I’m so looking forward to seeing everyone there. It’s my first JUG appearance in the new year, too!

So, let’s get to it!

Read more