A Kubernetes Tale: Part I — Building your Java project

A practical (and somewhat opinionated) guide to kick-off your project with Docker and Helm

Photo by Loik Marras on Unsplash

Generating our application

./gradlew bootRun

Running the application

Running the application standalone

A full list of the subtasks run by the build task: assemble, bootBuildImage, bootJar, build, buildDependents, buildNeeded…
A full list of the subtasks run by the build task: assemble, bootBuildImage, bootJar, build, buildDependents, buildNeeded…
A full list of the subtasks run by the build task
If you want to check the contents of the jar you can run jar tf build/libs/api-0.0.1-SNAPSHOT.jar
java -jar build/libs/dockeriser-0.0.1-SNAPSHOT.jar

Running the application with different flavours

java -Dspring.profiles.active=dev,container -jar build/libs/dockeriser-0.0.1-SNAPSHOT.jar

Why a “container” profile?

The main course: creating a Dockerfile

The JVM flags

Building and running your Docker image

docker build -t dockeriser .
docker run -P dockeriser:latest
A detailed list of the active running containers: image name, container id and age, bound ports, etc
A detailed list of the active running containers: image name, container id and age, bound ports, etc
If you run docker ps you’ll see a list of the running containers.
docker build -t dockeriser:`date +%Y%m%d_%H%M` .

Automate, automate, automate

./gradlew build
docker build -t dockeriser:`date +%Y%m%d_%H%M` .

Technology enthusiast. Less is more.

Get the Medium app