Properties file in Git or outside project?

我只是一个虾纸丫 提交于 2020-05-18 02:28:58

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/31313077/properties-file-in-git-or-outside-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!