Running apps
Environment variables
Keep API keys, passwords and settings in the app's variables rather than in the code. Database connections are given by Meghly itself.
Adding a variable
On the app's Environment page, give a name and a value. Keep anything secret (API keys, passwords) as a secret — once saved, a secret's value is never shown in the panel again; it can only be replaced.
A changed variable does not reach the running app by itself: restart the app or deploy again.
Naming rules
- Letters, digits and
_, not starting with a digit — such asSTRIPE_KEYorAPP_DEBUG. - Some names are set by Meghly and cannot be changed:
PORT, names starting withYOMAIL_, andDOTNET_RUNNING_IN_CONTAINER.
.NET: __ means a section
In ASP.NET Core, to set a value inside appsettings.json from a variable, write two underscores __ where the configuration path has ::
{
"Payment": { "ApiKey": "", "Sandbox": true }
}Payment__ApiKey = sk_live_...
Payment__Sandbox = falseDatabase variables
When a database is attached to the app, Meghly gives the connection as variables — nothing to type by hand:
| Variable | What |
|---|---|
DATABASE_URL | the whole connection URL (postgresql://…, mysql://…, sqlserver://…) |
DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD | the parts one by one (what Laravel reads) |
DB_CONNECTION | pgsql, mysql or sqlsrv |
ConnectionStrings__Default, ConnectionStrings__DefaultConnection | the .NET connection string |
Each engine also gets its familiar names: PGHOST, PGUSER … for PostgreSQL; MYSQL_HOST, MYSQL_USER … for MySQL/MariaDB; WORDPRESS_DB_HOST … for WordPress. With several databases, each also gets its own DATABASE_URL_<NAME>.
So in ASP.NET Core there is usually no code to change:
var connection = builder.Configuration.GetConnectionString("DefaultConnection");The running app's variables hold the database's runtime login (read and write). Tables are created and changed only in the release, with the migration login.
Redis
Attaching Redis to the app gives REDIS_URL, REDIS_HOST, REDIS_PORT, REDIS_USERNAME and REDIS_PASSWORD. Meghly manages these; to change them, remove Redis and add it again.
What not to keep in code
- Passwords, API keys and tokens — always in secret variables.
- Do not commit a
.envfile to the repository; give its values to Meghly as variables.