To provide secret keys and some further required configuration details, environment variables are added to the service.
During the development process you may have used an env.py file which contained sensitive information. For the application to perform correctly, this information is required in the production environment. When deploying to Heroku, you probably converted that file to a set of config vars.
You may have access to your env.py
file in a pinned workspace, but not necessarily. Luckily, Render provides a couple of ways to give your application access to these details without exposing them to the public.
This allows the addition of individual environment variables.
This would be a good place for development and debug variables when needed.
This file will be available ‘behind the scenes’, just like an env.py
file that is included in the .gitignore
. It is not accessible to the public, so the security and secrecy of its content are maintained.
This also acts as a nice backup location of production environment variables should a Gitpod workspace be lost without another external backup of the env.py
file.
If you do not have access to a copy of your env.py
file, please follow the steps below. If you do have access, please skip ahead.
Scroll down and click “Advanced”
Click “Add Environment Variable”
Open a new browser tab and navigate to your Heroku dashboard and open the Settings tab of your existing app
Click “Reveal Config Vars”
Copy each config var key and value from Heroku to a new Environment Variable on Render
Key | Value |
---|---|
IP | 0.0.0.0 |
PORT | 5000 |
SECRET_KEY | <your secret key> |
MONGO_URI | <your Mongo URI> |
MONGO_DBNAME | <your MongoDB name> |
DATABASE_URL | <your NEW ElephantSQL database URL> |
The IP
and PORT
variables are used within the Flask application and should not be modified.
Click “Save”
If you used an env.py
file to store your environment variables, and have access to it, please follow the steps below
Scroll down and click “Advanced”
Click “Add Environment Variable”
Copy the content of your existing env.py
file from Gitpod to your clipboard.
Return to Render and click “Add Secret File”
Paste in the copied text to the File contents text area input and ensure the Filename is env.py
Remove any environment variables that are only needed in Gitpod. For example DEV or DEVELOPMENT.
Click Save when done
Check your Heroku app config vars to ensure you have all the environment variables that your Render app will need. As some of these might not have been stored in your env.py
file. Use the same process as steps 1 - 3 to add any remaining config vars to Render.
The final option is whether to Auto-Deploy. The two options are explained in the following page.