0

I have a project in Spring Boot which is using the in-built web-server and angular as a front-end. When the Angular application is started, it reads the configuration from env.json which lies in the assets folder.

Now, I want to tell spring boot from outside, like env variables or a file as mount-point to propagate it to the assets folder. I want that the env.json within the assets folder contains the value corresponding to the outside env-variable I define.

With that approach I can use one container image and tell the app in which env it is.

This app is gonna be containerized and has to run in K8s.

Can someone give me a tip or approach to tackle this problem?

Here was a similar question Single build multi deployment for docker image created from Springboot+Angular Jar

Pass Angular environment variables to compiled static angular files in spring boot

v0ld3m0rt
  • 866
  • 3
  • 12
  • 47
Daywa1k3r
  • 11
  • 9
  • See my answer [here](https://stackoverflow.com/a/72786556/7381844) – jBuchholz Jun 28 '22 at 12:36
  • I can not create an extra endpoint because the app must know the endpoint url which is than also dynamic. And the other approacht with using envsubst does not work when you ship you app from one jar – Daywa1k3r Jun 28 '22 at 12:42
  • If you ship your Angular app inside of your Spring app they should have the same Url. Then you would just query the relative Url `assets/settings.js`. – jBuchholz Jun 28 '22 at 12:52
  • I do ship my Angular App as dependency in my Spring app. So you mean I can create a rest endpoint within the same app that listens exactly on /assets/settings.js. This endpoint can return just a normal json like { "env": "PRD" }? – Daywa1k3r Jun 28 '22 at 14:55
  • Why do you want to have the configuration inside the assets folder? – Thomas Jun 28 '22 at 16:10
  • It can be anywhere but within the same spring app. I want to start the spring app and provide some arguments so that angular bootstraps with a different setting/env – Daywa1k3r Jun 28 '22 at 16:17
  • You would not need to put it into assets. This would only be a convenience to provide the settings-file in a dev-environment easily. – jBuchholz Jun 29 '22 at 06:49
  • Can it be a random folder on the file system outside of the jar? – Daywa1k3r Jun 29 '22 at 08:13

0 Answers0