- Introduction
- Getting Started
- Gitpod Tutorial
- Use Cases
- Languages
- Configure
- Workspaces
- User settings
- Repositories
- Organizations
- Authentication
- Billing
- References
- .gitpod.yml
- IDEs & editors
- Integrations
- Gitpod CLI
- Gitpod API
- Gitpod URL
- Compatibility
- Enterprise
- Overview
- Setup and Preparation
- Deploying
- Configure your Gitpod Instance
- Administration
- Upgrading
- Background
- Reference
- Archive
- Help
- Contribute
- Troubleshooting
Step 5: Configure environment variables
Up until now, we’ve installed our tooling—but all of our configurations have been hardcoded. But, what if we have some configuration to use in our application? Let’s update the db.js
file in the repo to use environment variables set with Gitpod.
You can set environment variables inside a workspace using gp env
(from the Workspace CLI). To see currently set environment variables, run gp env
:
bash
gp env
Let’s use gp env
to set our environment variables:
bash
eval $(gp env -e USER=gitpod)
eval $(gp env -e DATABASE=eventhub_db)
And reference the variables in our db.js
file by updating it to:
javascript
const { Pool } = require('pg');
const pool = new Pool({
user: process.env.USER,
host: 'localhost',
database: process.env.DATABASE,
password: '',
port: 5432,
});
module.exports = pool;