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 as STRIPE_KEY or APP_DEBUG.
  • Some names are set by Meghly and cannot be changed: PORT, names starting with YOMAIL_, and DOTNET_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 ::

appsettings.json
{
  "Payment": { "ApiKey": "", "Sandbox": true }
}
Environment
Payment__ApiKey = sk_live_...
Payment__Sandbox = false

Database variables

When a database is attached to the app, Meghly gives the connection as variables — nothing to type by hand:

VariableWhat
DATABASE_URLthe whole connection URL (postgresql://…, mysql://…, sqlserver://…)
DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORDthe parts one by one (what Laravel reads)
DB_CONNECTIONpgsql, mysql or sqlsrv
ConnectionStrings__Default, ConnectionStrings__DefaultConnectionthe .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:

Program.cs
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 .env file to the repository; give its values to Meghly as variables.

Stuck?

Talk to our engineers directly — by phone or email.

01782618248shohag.meghly@gmail.com