Spring Boot can load property files from the jar directory as described here
However, this does not seem to work when building a native image using graalvm.
What I do ist build a native image using bootBuildImage
.
I try to mount a example configruation into my docker container like this:
docker run -d -v application.yaml:/cnb/process/application.yaml <registry>/api-prober
I also tried
docker run -d -v application.yaml:/cnb/process/application.yml <registry>/api-prober
docker run -d -v application.yaml:/workspace/application.yml /api-prober
From what I can see, /cnb/process is the entrypoint and I assume the binary resides in this folder, however, the config does not get picked up.
How can I use externalized configuration with graalvm and spring boot?
Edit: The striked- through variant seems to work.
2
Answers
After some research, trial and error and typos I found out, that the default executable directory is
/workspace
so if you run it with
docker run -d -v application.yaml:/workspace/application.yml /api-prober
Spring picks up my config file on startup
In the link you mentioned in the question, SpringBoot will find for config file in current directory, not the jar directory. I reckon maybe the working directory in docker image is not the directory that jar exists.