What's the simplest way to run a spring boot kotli...
# spring
p
What's the simplest way to run a spring boot kotlin app inside docker? My attempt does not work, it freezes 😞
Copy code
docker run --user $(id -u) --volume "$PWD":/home/gradle/project --workdir /home/gradle/project gradle:7-jdk17 gradle --no-daemon --no-rebuild --no-scan --no-watch-fs --no-parallel bootRun
(to which channel does this question fit?)
t
bootJar
does packaging, you probably want
bootRun
instead
p
Ah, that's a real typo, but the effect is the same. (thanks, corrected)
t
or, you can create the image with
./gradlew bootBuildImage --imageName=myorg/myapp
and then run it with
docker run -p 8080:8080 -t myorg/myapp
🙏 1
👍 1
a
Super simple to install and use. There's options for building the container straight to local Docker install or you can send the image to any of the cloud-based repositories (I use AWS ECR).
Lastly Jib is magical in a CI/CD pipeline because it does not actually require Docker to be installed. I've been using it for about 2 years and would not use anything else for container creation
One you install it in your build file (the Gradle plugin, I mean) it's just
./gradlew jubDockerBuild
and then just start the container - your SpringBoot app launches automatically and normally - no commands needed. Magic
p
How is it different from bootBuildImage suggested by @thanksforallthefish?
a
Dunno, have not used bootBuildImage
According to the buildBootImage doc, "The
bootBuildImage
task requires access to a Docker daemon". Job does not require that - hence a CI/CD is simpler to set up
Other than that the two seem quite similar, the Gradle Jib config looks simpler to my eyes, but I've been using it for years, so I am biased
p
Thanks for both of you!
🙇 1
So, it works, but it is painfully slow btw.
a
Which "it"?
p
./gradlew bootBuildImage, but seems like it is just the first time, when it pulls images from net.
a
That and it's building "layers". Later image builds will only create the changed layers. Also, at least in my experience with Jib, pushing to cloud repos (ECR) is significantly faster as it pushes only the changed layers - very elegant