如何将私有信息添加到 OpenShift 环境变量? [英] How can I add private information to OpenShift environment variables?

查看:28
本文介绍了如何将私有信息添加到 OpenShift 环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数据库连接字符串或密码等身份验证信息几乎不应该存储在版本控制系统中.

Authentication information such as database connection strings or passwords should almost never be stored in version control systems.

似乎为 OpenShift 上托管的应用程序指定环境变量的唯一方法是 将它们提交到 Git 存储库.关于这个的讨论在OpenShift 论坛,但没有针对该问题的有用建议解决方法.

It looks like the only method of specifying environment variables for an app hosted on OpenShift is to commit them to the Git repository. There is a discussion about this on the OpenShift forums, but no useful suggested workarounds for the problem.

我可以使用另一种方法将身份验证信息添加到我的应用程序,而无需将其提交到存储库吗?

Is there another approach I can use to add authentication information to my app without having to commit it to the repository?

推荐答案

SSH 进入你的应用程序并导航到你的数据目录

SSH into you application and navigate to your data directory

cd app-root/data

在此目录中创建一个包含变量的文件(例如.myenv"),其内容类似于

in this directory create a file with your variables (e.g. ".myenv") with content like

export MY_VAR="something"

然后在您的存储库中的.openshift/action_hooks/pre_start"中添加这一行

and then in your repository in ".openshift/action_hooks/pre_start" add this line

source ${OPENSHIFT_DATA_DIR}/.myenv

这篇关于如何将私有信息添加到 OpenShift 环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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