1

This is kind of a general question, I've never had to deploy my own code and I'm not sure how to go about doing this properly.

I have a file in my project that creates a mongoose object and connects to a remote Mongo db (not a db created in openshift). The connection string contains my user and password so I set it to be ignored by git so it wouldn't be public.

mongoose.connect( 'mongodb://$Username:$password@ds111111.mlab.com:49551/db_name' );

But now I run into the problem that when I create a build from my git source, obviously this file isn't there and the application crashes.

What's the right way to go about this?

SpringsTea
  • 57
  • 2
  • 8

2 Answers2

2

There are many ways to do what you need to do. But the suggestions outlined here are commonly used in the industry. The config section is what you are looking for in particular.

The gist of it is that you should store your secrets in environment variables. Here is a Stack Overflow question that might be helpful.

mkhanoyan
  • 1,958
  • 18
  • 15
0

What version of OpenShift are you using?

If you are talking about OpenShift 3, you can declare environment variables on the deployment configuration. These can have the value for the environment set in the deployment configuration itself, or you can use a separate secrets object and reference the value for the environment variable from the secret. Secrets can instead be mounted into the running container as a file and an application can read the credentials from the file.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134