Different versions of the same configuration file in different branches

不羁岁月 提交于 2020-01-02 08:28:13

问题


We are using dotCloud, a virtual host, to run some of our apps. dotCloud deploys apps directly from a git repo, and reads a configuration file called dotcloud.yml from that repo to configure and run the stack.

We have two branches (one production, one staging) that are part of the same repo, and these push to separate dotCloud instances. There is a minor difference in the dotcloud.yml file to run each of these instances.

What is the best way to manage this dotcloud.yml file? Currently we simply make sure we're making sure the dotcloud.yml is correct on each branch, but it constantly gets overwritten as we merge changes from staging to master.


回答1:


You could:

  • version a dotcloud.yml.template
  • version a dotcloud.yml.value.prod and a dotcloud.yml.value.staging with the pertinent values for each environment.
  • version a smudge script in charge of building the right dotcloud.yml file (which wouldn't be versioned anymore) depending on dotCloud instance.

You would declare that smudge script as a filter content driver in a (also versioned) .gitattribute file:

On any git checkout, the smudge script will be called and, if it recognized the dotcloud.yml.template content, will build the right dotcloud.yml file.




回答2:


You could:

  • add dotcloud.yml to .gitignore, have two separate files for staging and production (e.g. dotcloud.yml.staging and dotcloud.yml.production), both present in your git repository, setup a symlink dotcloud.yml → dotcloud.yml.production, and push with dotcloud push --rsync (the --rsync flag will override the push mechanism detection, and the rsync mechanism will kick in, instead of the git mechanism);
  • use the same dotcloud.yml file, but rely on a different mechanism (e.g. dotcloud var or a postinstall script) to switch between the production and staging behaviors.


来源:https://stackoverflow.com/questions/10426954/different-versions-of-the-same-configuration-file-in-different-branches

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