Skip to content

Type a word or two, like firewall or rollback.

Open Coresmith
Browse the docs
Apps Checked against Coresmith 0.8.44.

Set environment variables

Open as Markdown

Edit the variables

  1. On the app's page, choose Edit variables on the Environment card.
  2. Write one KEY=value per line.
  3. Save, then deploy. The new values apply from the next deploy.

The values reach the app's processes when they start. Deploy logs hide them.

Start from .env.example

If the repository has a .env.example, .env.sample, .env.dist or .env.template, a new app's variables start from it:

  • Values from the file are kept.
  • Values whose names look secret, such as keys, passwords and tokens, start blank, so fill those in. On the Environment card, a variable with no value reads not set.
  • Database and Redis settings come from the database you pick when you add the app.
  • Development settings such as APP_ENV, APP_DEBUG and NODE_ENV are left out, so production values apply. A Laravel app gets APP_ENV=production, APP_DEBUG=false and APP_URL from its domain.

A repository without one gets a hint on Add an app. Commit one, and every new app starts with the settings it expects. Without one, a Laravel app still starts with its name in APP_NAME, a new APP_KEY, the production settings above and LOG_LEVEL=error.

What Coresmith fills in

When the app doesn't set them itself, Coresmith adds what its framework needs to run in production:

  • Laravel: an APP_KEY, generated once and kept.
  • Symfony: production settings and an APP_SECRET.
  • Rails: a SECRET_KEY_BASE, plus RAILS_ENV=production and WEB_CONCURRENCY=0, which runs Puma as one process.
  • Django and Flask: a SECRET_KEY.
  • Node.js, Bun and Deno: NODE_ENV=production, and the port to listen on.

Switches on the app's page add their own settings, such as Reverb's host and keys.

Database details

When you pick a database on Add an app, or create or pick one on the app's page, Coresmith writes its connection into the variables under the names the app reads:

  • Laravel, and apps that already use these names: DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME and DB_PASSWORD.
  • Spring Boot: SPRING_DATASOURCE_URL, SPRING_DATASOURCE_USERNAME and SPRING_DATASOURCE_PASSWORD.
  • Everything else: DATABASE_URL.
  • Redis: REDIS_HOST, REDIS_PORT and REDIS_PASSWORD for Laravel, or REDIS_URL.

The Environment card names the databases the app is connected to. When a connected database's password changes, or its Redis moves to a port of its own, Coresmith updates the app's variables. Deploy the app to switch over.

When the variables expect a database that isn't there

Before an app's first release, Coresmith compares its variables with the databases on its server. If they expect PostgreSQL, MySQL or Redis on the server itself and nothing matches, the app's page says what's missing and offers to create it, or to use a database that's already there. Either way, Coresmith rewrites the connection settings. This catches variables copied from another server, which often name a database that doesn't exist on the new one.

Who can see them

Owners, Admins, and Developers who can change the app can read and edit its environment. Deployers see the variable names, with the values hidden. Values whose names look secret, such as keys, passwords and tokens, stay hidden on the card for everyone until you open the editor.