简体   繁体   中英

Properties file in Git or outside project?

We are developing a spring based web application that needs to be deployed in various of environments:

1) developers local machines in order to develop new features \\ fix bugs etc.

2) QA Env#1 - for the QA team to test our releases

3) QA Env#2 - for the QA team to test our releases

4) QA Env#3 - for the QA team to test our releases

5) Production

Now, each deployment for one of these environments requires to fill a properties file, this file contains many parameters :

1) tomcat ips

2) mysql ip

3) mongo ip

4) load balancer ip

5) ehcache multi cast ports and addresses.

6) many many more

Our question is:

Where this properties file should be defined? in our code base? (git, in a folder for each environment?) outside the our webapp project (this way, every environment should be updated with the correct properties file once, and then the deployment is straight forward with no configurations at all)?

Bear in mind we are working on a build\\deploy machine that will automatically deploy our project to all of these envs, so this is something to keep in mind when deciding the correct way to handle this.

In general, I would not keep properties files in a repository, even though we are talking about a private one. Some reasons that come to my mind are:

  • Versioning is not needed . I personally see no point in keeping the version history of deployment or QA property files.

  • Customer privacy. You might not want to share deployment configuration with all people having access to the repository (developers, QA team, ...).

  • Preventing errors. Errors happens. A developer committing by mistake some changes to the deployment or QA property files might cause some serious troubles to your build/deploy chain.

What you can do is add to your repository some templates for the property files that contain a default configuration for your application (for instance the local developer configuration).
You can then have different property files for different environments that you distribute only within the involved teams (QA configuration to QA team, deployment configuration only for the deployed system).

Your build\\deploy machine will most likely have access to all different property files and can retrieve the correct one depending on the target environment. With such configuration you have no benefit from keeping such files in the repository, it is enough to store them in a location available to people entitled to change them and to the build\\deploy machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM