Git或外部项目中的属性文件? [英] Properties file in Git or outside project?

查看:82
本文介绍了Git或外部项目中的属性文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个基于Spring的Web应用程序,该应用程序需要部署在各种环境中:



1)开发人员本地机器以开发新功能\修复错误等。



2)质量检查环境#1-供质量检查小组测试我们的版本



3) QA Env#2-供质量检查小组测试我们的版本



4)QA Env#3-供质量检查小组测试我们的版本



5)生产



现在,这些环境之一的每个部署都需要填充属性文件,该文件包含许多参数:



1)tomcat ips



2)mysql ip



3)mongo ip



4)负载均衡器ip



5)ehcache多类型转换端口和地址。 / p>

6)还有很多



我们的问题是:



应在哪里定义此属性文件?在我们的代码库中? (git,是否在每个环境的文件夹中?)在我们的Webapp项目之外(通过这种方式,应使用正确的属性文件一次更新每个环境,然后直接进行部署而无需进行任何配置)?



请记住,我们正在开发一台构建\部署机器,该机器会自动将项目部署到所有这些环境中,因此在决定时要牢记这一点正确的处理方式。

解决方案

通常,即使我们在谈论,我也不会将属性文件保留在存储库中关于一个私人的。我想到的一些原因是:




  • 不需要版本。我个人认为保留部署或QA属性文件的版本历史毫无意义。


  • 客户隐私。您可能不想


  • 防止错误。发生错误。错误地对 deployment QA 属性文件进行某些更改的开发人员可能会对您的构建/部署链造成严重的麻烦。




您可以做的是向存储库中添加一些 templates 用于属性文件包含应用程序的默认配置(例如 local 开发人员配置)。

然后,您可以拥有针对不同环境的不同属性文件,这些文件仅在相关团队中分发(质量检查)配置给质量检查小组,(已部署系统的部署配置)。



您的构建部署机器很可能可以访问所有不同的属性文件,并且可以根据目标环境检索正确的属性文件。使用这种配置,将这些文件保存在存储库中并没有任何好处,将它们存储在有权进行更改的人员和build\deploy机器可用的位置。


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.

这篇关于Git或外部项目中的属性文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆