部署环境和代码分支之间有什么区别?

发布于 2025-01-22 08:48:01 字数 585 浏览 3 评论 0原文

介绍

我正在研究一个具有不同部署环境的应用程序:

  • 开发(开发)
  • UAT(用户接受测试)
  • 产品(生产)

我知道,新版本的开发发生在Dev中,将用于测试的UAT,然后推入实际使用。使用不同的环境来确保开发人员可以在不打扰应用程序的实际用户的情况下进行错误并犯错误。

但是,当需要“ hotfix”(=需要紧急修复的错误)时,我有点困惑。一位同事告诉我,在这种情况下,产品环境的代码被“分支”并推向开发人员。当错误固定在开发处时,将分支推到进一步的UAT,最后再次引起。即使已经有一些开发项目的开发项目,但由于“ hotfix”是在不同的“分支”上完成的,因此仍然不会丢失这项工作。

问题

是否与部署环境和代码分支之间的差异有关,对吗?

  • 代码分支只是代码库的副本,该代码库开始过着单独的寿命,直到再次与主代码分支合并为止。
  • 部署环境是一个具有代码的环境,该环境是与代码进行交互的数据库以及计算执行代码的能力。

因此,区别主要是部署环境在纯“代码”之上具有数据库和计算能力。

Intro

I'm working on an application that has different deployment environments:

  • DEV (development)
  • UAT (user acceptance testing)
  • PROD (production)

I understand that development for a new release happens in DEV, is pushed to UAT for testing and then pushed to PROD for actual usage. Different environments are used to makes sure that developers can play around and make errors without disturbing actual users of the application.

However I'm a bit confused about what happens when a "hotfix" (=bug that needs to be fixed urgently) is required. A colleague told me that in this case the code of the PROD environment is "branched" and pushed to DEV. When the bug is fixed on dev, the branch is pushed further to UAT and finally PROD again. Even if there were already some developments for a next release in DEV, then still this work would not be lost as the "hotfix" is done on a different "branch".

Question

Is the following understanding, relating to the difference between deployment environments and code branches, correct?

  • A code branch is just a copy of a codebase that starts living a separate life until it is merged with the main code branch again.
  • A deployment environment is an environment that has code, a database for the code to interact with and computing power to execute the code.

The difference is thus mainly that the deployment environment has a database and computation power on top of the pure "code".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

霞映澄塘 2025-01-29 08:48:01

你几乎是正确的。分支 - 通常是git分支 - 是在某个时间点上从代码库中的叉/副本。在您的情况下,您的分支“ hotfix”是“主”分支的副本。您根据需要修改代码,然后将其合并到“主”中。

部署环境是代码库特异性分支的实例。它在物理机器功能和配置变量方面有所不同。

数据库凭据(URL,用户名和密码)就是一个很好的例子,因为每个部署都应处理自己的数据。外部API的键和访问令牌应作为环境变量保存,而在代码库中,您尝试从环境中读取它。

这样,如果您的应用程序创建订单 - >调用付款网关API - >向客户发送电子邮件 - >等等,在开发中,您将调用沙盒API,而不是采取付款的行动并为真实发送电子邮件。开发人员不知道其他服务的实际凭证或访问密钥。

12Factors应用程序将为您提供更多令人满意的知识。

you're almost correct. a branch -often a git branch- is a fork/copy from the codebase at a certain point in time. in your case, your branch "hotfix" is a copy from "master" branch. you modify the code as needed, then merge it back into "master".

a deployment environment is where an instance of codebase -specific branch- runs. it differs in terms of the physical machine capabilities, and configuration variables.

database credentials (URL, username, and password) are a good example, as each deployment should deal with its own data. external APIs' keys and access tokens should be kept as environment variables, while inside the codebase you attempt to read it from the environment.

that way, if your app creates an order -> calls a payment gateway API -> sends an email to the customer -> etc, in development you will be calling a sandbox API, not taking the action of payment and sending email for real. and developers do not know the real credential or access keys for other services.

12factors app will give you more satisfying knowledge.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文