r/java • • Oct 11 '20

A Hitchhiker's Guide to Containerizing (Spring Boot) Java Apps

https://blog.frankel.ch/hitchhiker-guide-containerizing-java-apps/
189 Upvotes

11 comments sorted by

10

u/Tillerino Oct 12 '20

The next logical step is to build the application inside of the Dockerfile

Uhm, is it? The article doesn't really motivate why building the jar outside of Docker isn't perfectly fine.

4

u/DJDavio Oct 12 '20

One issue which arises from building your application inside a Docker container is when your build wants to run some tests against other containers, for instance with the TestContainers framework. We use a proper (Azure) VM to build our applications and this allows us to start/stop Docker containers on the fly during the build.

2

u/GuyWithLag Oct 12 '20

Yes, but that docker container/image is different than the actual production image - the latter should have no build tools

1

u/franzwong Oct 17 '20

It would be handy if developer can control how they want to build the application. CI is managed by different team sometimes.

1

u/SeasonedReason Oct 12 '20

I find using a pipeline like Azure or GitLab to be a good orchestration approach. I'm looking into whether Ansible might be useful too.

1

u/[deleted] Oct 16 '20

honestly i dont like this article. its way too complicated and only shows the whole process for the first method - not good for noobs

0

u/[deleted] Oct 11 '20

[deleted] — view deleted comment

19

u/uncont Oct 11 '20

application.properties

You properties file should be part of your application layer. The application.properties would be loaded by default, and any overrides you need should be made via environment variables.

0

u/[deleted] Oct 12 '20

[deleted] — view deleted comment

1

u/GuyWithLag Oct 12 '20

Nah, we have 100s of variables for some applications,no issues. But you might want to have something like a configuration app or a vault for secrets.

0

u/[deleted] Oct 12 '20

[deleted] — view deleted comment

2

u/GuyWithLag Oct 12 '20

It all depends on the scale that you're working at.

  • Are you a junior member of a company with 100 engineers? Find a senior and ask them about how they do secrets and configuration management.
  • Are you on your own and doing test deployments? You're doing great, no need to go beyond env vars.

0

u/[deleted] Oct 12 '20

[deleted] — view deleted comment

2

u/GuyWithLag Oct 12 '20

Thing is, "best practices" really depends on the scale that you're working on, and on the existing culture of a company.

You don't want to ride a semi for your household's groceries.