Hi,
we need to distinguish between development and production use. The environment 
variables here are only needed for development purposes.
When adding the env settings to the application.properties, they will be also 
in the classpath of the packaged jar and would therefore override production 
settings (something we don't want).
When adding the env settings to the pom file, they will be only available when 
running mvn spring-boot:run and won't affect the final jar (which is what we 
want for development purposes).

Dominik  

-----Original Message-----
From: Johannes Tex <[email protected]> 
Sent: Friday, July 24, 2020 10:28 AM
To: [email protected]
Subject: Re: Added RunConfigurations as Project Files for IntelliJ

Hi All,

i usually use *application.properties* file [1] for Spring boot Applications to 
set my enviroments varibales. I think it does the same as setting via POM? 

The advantage is that the Spring boot Application check if the env var is set 
in the system, and if not, it taking the default value. E.g:

application.yml
-----
eureka:
  client:
    serviceUrl:
      defaultZone: http://${eureka.address:localhost:8761/eureka/} 
#envName:Default


In this case the application checks if the env "eureka.address" is set and if 
not, the default value "localhost:8761/eureka/" is takken (Dev). For production 
I only set the environment variable in docker "eureka.address" to 
"eureka:8761/eureka/".

Maybe this would be also a solution for StreamPipes?

Johannes

[1] https://www.baeldung.com/properties-with-spring#6-alternative---yaml-files

On 2020/07/24 05:22:32, Patrick Wiener <[email protected]> wrote: 
> Indeed. Thats a good point. We need to make sure that this is not 
> leading to some conflicts when starting in a docker container and setting the 
> env variables from the docker-compose or k8s manifest.
> 
> Idk but is there any spring boot magic that we can tell it it’s only a dev 
> profile setting?
> 
> Patrick
> 
> > Am 23.07.2020 um 22:49 schrieb Philipp Zehnder <[email protected]>:
> > 
> > Hi Patrick,
> > 
> > you are right. The solution did just work for IntelliJ. But this pull 
> > request should fix this problem [1]. There the environment variables are 
> > defined in the pom file. The services can be started direclty from the 
> > command line. I would additionally keep the IntelliJ configuration to ease 
> > the setup for users, but we should remove the environment variables from 
> > this configuration.
> > I was wondering what happens when this runs in docker? Are the new 
> > environment variables then used as well? If this is the case, we need a 
> > solution to change the default values for productions. 
> > 
> > We should definitely update the documentation. Where should we put this 
> > kind of information?
> > 
> > Philipp
> > 
> > 
> > [1] https://github.com/apache/incubator-streampipes/pull/25 
> > <https://github.com/apache/incubator-streampipes/pull/25>
> > 
> >> On 20. Jul 2020, at 10:46, Patrick Wiener <[email protected]> wrote:
> >> 
> >> Hi all,
> >> 
> >> While it works on Mac/Windows hosts, a problem that still arise and 
> >> we should be aware of is on Linux based development environments, 
> >> where the developers host is a Linux OS. The problem occurs due to 
> >> the fact that Docker on Linux cannot resolve host.docker.internal
> >> 
> >> Thus, the developer would need to adjust the env variable in the run 
> >> Configuration manually:
> >> 
> >> as per specified run config - fine for OSX/Windows:
> >> 
> >> SP_PORT=6025;SP_HOST=host.docker.internal;SP_DEBUG=true
> >> 
> >> Linux:
> >> SP_PORT=6025;SP_HOST=<HOST_IP or DOCKER0_BRIDGE>;SP_DEBUG=true
> >> 
> >> On Linux, the developer has two options:
> >> 
> >> 1) set SP_HOST to his/her host IP —> Problem: not agnostic to 
> >> changing network environments
> >> 2)  set SP_HOST to docker0 bridge IP —> should be agnostic to 
> >> changing network environments [Preferred]
> >> 
> >> He/she can look up the IP’s via ifconfig.
> >> 
> >> We definitely need to update the documentation as well - not only in the 
> >> repositories. Currently it states that you’d still need the env File 
> >> plugin.
> >> Maybe because we haven’t updated the archetypes as well?
> >> 
> >> One minor: Overall this solution only works with Intellij IDE - not 
> >> Eclipse for instance.
> >> 
> >> 
> >> Patrick
> >> 
> >> 
> >>> Am 02.07.2020 um 15:38 schrieb Philipp Zehnder <[email protected]>:
> >>> 
> >>> Hi,
> >>> 
> >>> @Felix, very cool. Everything works fine and I merged it into dev.
> >>> 
> >>> @Patrick, I removed the configurations for the EnvFile plugin in the 
> >>> configuration XML, so we should not need this anymore.
> >>> 
> >>> @All: Any ideas for naming the services? Because now we have a quite long 
> >>> list in the run configurations. I would suggest to  use a prefix for the  
> >>> Processor Containers and the backend services?
> >>> The core and connect master already have the prefix “Apache StreamPipes”, 
> >>> but I think this is a bit too long. Any ideas or suggestions?
> >>> 
> >>> Philipp
> >>> 
> >>>> On 2. Jul 2020, at 11:17, Felix John <[email protected]> wrote:
> >>>> 
> >>>> Hi Patrick,
> >>>> 
> >>>> good question. I just tested one configuration whilst disabling the 
> >>>> "EnvFile" plugin. I worked out nicely.
> >>>> 
> >>>> 
> >>>> Greetings,
> >>>> Felix
> >>>> 
> >>>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> >>>> On Wednesday, 1. July 2020 22:03, Patrick Wiener <[email protected]> 
> >>>> wrote:
> >>>> 
> >>>>> Hi Felix,
> >>>>> 
> >>>>> cool - that def helps the onboarding process for those using IntelliJ.
> >>>>> 
> >>>>> Do these runConfigurations also need to have the env-File plugin 
> >>>>> pre-installed to work?
> >>>>> 
> >>>>> Patrick
> >>>>> 
> >>>>>> Am 01.07.2020 um 18:34 schrieb Felix John [email protected]:
> >>>>>> Hi,
> >>>>>> I have added Run Configurations as project files for IntellJ so that 
> >>>>>> you no longer have to create the configurations manually. The 
> >>>>>> configuration files can be found here: .idea/runCofigurations.
> >>>>>> These files are only recognized by IntellJ if the folder 
> >>>>>> .idea/runCofigurations is located in your working directory. Because 
> >>>>>> the working directory setup in IntelliJ might vary from user to user, 
> >>>>>> I added the folder .idea/runCofigurations to incubator-streampipes as 
> >>>>>> well as incubator-streampipes-extension.
> >>>>>> This feature can be found in the branch run-configurations.
> >>>>>> Greetings,
> >>>>>> Felix
> >>>> 
> >>>> 
> >>> 
> >> 
> > 
> 
> 

Reply via email to