App Engine:基于环境的不同app.yaml文件 [英] App Engine: different app.yaml files based on environment

查看:250
本文介绍了App Engine:基于环境的不同app.yaml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将应用程序迁移到依赖于各种外部连接的环境变量的Google App Engine。看起来app.yaml文件是我应该设置这些配置的地方,但是如何管理这些变量可能不同的不同环境(开发,测试,分期,生产)?

I am currently migrating an application to Google App Engine that relies on environment variables for various external connections. It looks like the app.yaml file is where I should setup these configurations however how do I manage different environments (development, testing, staging, production) where these variables may be different?

只需使用不同的app.yaml文件为每个环境创建一个分支,最简单的解决方案?

Is the easiest solution just to create a branch for each of these environments with just a different app.yaml file?

推荐答案

app.yaml 可以为应用程序的其余部分设置环境变量,但是没有办法检查并根据输入的值进行不同的处理。因此,您需要向您使用的任何部署过程提供不同的 app.yaml 文件。

app.yaml can set environment variables for the rest of the application, but it has no way to check them and do different things depending on their incoming values. Thus, you do need to present different app.yaml files to whatever deployment procedure you're using.

As为了准备正确的最佳方法 app.yaml 作为GAE部署的初步步骤,这是一个微妙的漏洞问题。你们git或hg中的分支或者你所提到的任何事情都可以工作,但是个人(也许只是坏运气) - 我经常发现我的结构越简单,分支越来越长(如反对临时偏差意图很快就会并入后备箱)给了我更严重的头痛。

As for the best way to prepare the right app.yaml as a preliminary step to GAE deployment, that's a subtler devops problem. Branches in your git or hg or whatever, as you mention, would work, but personally (maybe just bad luck?-) I've often found that the simpler my structure, the better, and branches intended to be long-lived (as opposed to temporary deviation intended to be soon merged back into the trunk) have given me the worse headaches.

所以,由我来说,我会有一个 preapp.yaml 模板(可能是jinja2,无论如何)需要的if / else逻辑,并准备正确的 app.yaml 作为任何部署的第一步,使用简单的Python脚本。

So, were it up to me, I'd have a preapp.yaml template (maybe jinja2, whatever) with the needed if/else logic, and prepare the right app.yaml from it, as the very first step of any deployment, with a simple Python script.

几乎所有类型的架构(对于各种配置文件,因此对于目前测试版的 gcloud预览部署管理器,请参阅 https://cloud.google.com/sdk/gcloud/reference/preview/deployment-manager/ ,所以cour我可以偏向于这种方法(但是正如我所提到的,我的偏见主要来自于以前的不良部署经验: - )。

Pretty much the kind of architecture used (for all kind of configuration files, and thus with more inevitable complications) for the currently-beta gcloud preview deployment-manager, see https://cloud.google.com/sdk/gcloud/reference/preview/deployment-manager/ , so of course I could be biased towards the approach (but as I mentioned my bias comes essentially from previous bad deployment experiences:-).

这篇关于App Engine:基于环境的不同app.yaml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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