0

I want to put a file inside an image generated by spring boot native image. But as far as I tried to search, there's no such option (or I couldn't find it) in neither spring boot maven plugin, paketo buildpack nor graalvm itself. I found that you can put resources in using -H:IncludeResources, however I need an actual file inside image's filesystem.

Widowan
  • 1
  • 1

1 Answers1

0

One approach is to have files as resources, read them using Class::getResource, and embed them into the image using -H:IncludeResources.

Remember native images are not Docker images, they don't have "filesystem" inside. They are just regular executables.

peterz
  • 306
  • 1
  • 3
  • Not sure its a good idea, but you could embed the contents of what you want as a multi-line string. You could also set an argument or system property to point your application to a directory where it can find the resources it requires. You just need to ship those with the binary, which is where a container image comes in handy. – Daniel Mikusa Mar 01 '23 at 13:37
  • "> Remember native images are not Docker images, they don't have "filesystem" inside. They are just regular executables." I think that's my problem. When looking inside generated image, I noticed there's only one executable and nothing else, so maybe it is indeed not possible (I though it is because of mentions of /workspace being default directory and implications of it). – Widowan Mar 02 '23 at 11:27