Using Environment Variables
Environment variables are a powerful way to configure your applications without modifying code. They allow you to customize your application’s behavior, store configuration settings, and manage sensitive information like API keys and database credentials.What Are Environment Variables?
Environment variables are dynamic values that can affect the way running processes behave on a computer. In the context of containerized applications, they provide a way to:- Configure application settings
- Store API keys and credentials
- Toggle features on and off
- Set configuration options
- Define connection parameters
Managing Environment Variables on RepoCloud
RepoCloud makes it easy to set, update, and manage environment variables for your applications through a simple web interface.Accessing Environment Variables
Adding Environment Variables
Enter Key and Value
Enter the variable name (key) and its valueExample:
- Key:
DATABASE_URL - Value:
mysql://user:password@localhost:3306/mydatabase
Editing and Deleting Variables
Changes to environment variables typically require an application restart to take effect. RepoCloud automatically handles this for most applications.
Sensitive Information and Security
Environment variables are commonly used to store sensitive information like API keys, passwords, and tokens. RepoCloud implements security measures to protect this data:- Encryption: Environment variable values are encrypted at rest
- Masked Display: Sensitive values are masked in the interface (displayed as
••••••••) - Access Control: Only authorized users can view and modify environment variables
- No Logging: Sensitive values are not written to application logs
Common Environment Variables
Different applications use different environment variables, but some common categories include:Database Connection Strings
Database Connection Strings
Variables that define how your application connects to a database:
API Keys and Authentication
API Keys and Authentication
Variables for third-party service integration:
Application Settings
Application Settings
Variables that control application behavior:
Email Configuration
Email Configuration
Variables for email service configuration:
Application-Specific Variables
Each application has its own set of supported environment variables. Here are examples for some popular applications:WordPress
WordPress
Common WordPress configuration variables:
Node.js Applications
Node.js Applications
Common Node.js application variables:
PostgreSQL
PostgreSQL
PostgreSQL configuration variables:
Best Practices
Follow these best practices when working with environment variables:- Use descriptive names: Choose clear, descriptive names for your variables
- Separate development and production: Use different values for development and production environments
- Document your variables: Keep a record of what each variable does and why it’s needed
- Minimize sensitive data: Only store sensitive information in environment variables when necessary
- Use standard formats: Follow established formats for connection strings and other structured data
- Avoid hardcoding: Never hardcode values that should be configurable in your application code
Troubleshooting
Application Not Recognizing Variables
Application Not Recognizing Variables
If your application doesn’t recognize environment variables:
- Verify the variable name is correct (including case)
- Ensure the application has restarted after changes
- Check application logs for environment-related errors
- Verify the application is designed to use the variables you’re setting
Syntax Errors
Syntax Errors
Some common syntax issues:
- Avoid spaces around the equals sign (use
KEY=value, notKEY = value) - Be careful with quotes (some values may need to be quoted)
- Watch for special characters that might need escaping
Changes Not Taking Effect
Changes Not Taking Effect
If changes don’t seem to apply:
- Manually restart the application after changing variables
- Check if the application caches configuration and needs a specific refresh
- Verify you’ve saved the changes in the dashboard
