Appearance
Variables and references
Every service has its own environment variables, per environment. They are encrypted at rest and given to the container when it starts, and to the build for GitHub sources (see Build variables).
Editing variables
Open the service's Variables tab. Add variables one by one, or open the raw editor and paste a .env file (KEY=value per line). Saving in the raw editor replaces all variables in the list.
Names must start with a letter or underscore and contain only letters, digits and underscores.
Saving changes redeploys the service if it is running, so the new values take effect.
References
A value can contain references in ${{ }}. They are resolved when the service is deployed, inside the same environment.
| Syntax | Resolves to |
|---|---|
${{VAR}} | Another variable of the same service, including the automatic variables. |
${{Service.VAR}} | Variable VAR of the service called Service in the same environment. The service name is case-insensitive. |
${{shared.VAR}} | The environment's shared variable VAR. |
${{secret(N)}} | Replaced once, when you save it, by a random string of N letters and digits (8 to 128). |
Examples:
bash
# connect to the project's PostgreSQL
DATABASE_URL=${{Postgres.DATABASE_URL}}
# build a URL from another service's private hostname
API_INTERNAL_URL=http://${{api.FJORDRUN_PRIVATE_DOMAIN}}:8080
# the frontend's public URL, for CORS
CORS_ORIGIN=https://${{web.FJORDRUN_PUBLIC_DOMAIN}}
# a value shared by every service in the environment
SENTRY_DSN=${{shared.SENTRY_DSN}}
# generate a secret once
SESSION_SECRET=${{secret(48)}}Rules:
- References can be combined with text and with each other in one value, and can point at values that contain references themselves (up to 6 levels deep).
- A reference to a service or variable that does not exist resolves to an empty string. Check spelling if a value comes out empty.
- References stay references: if the referenced value changes, the next deployment of your service uses the new value. Changing another service's variable does not redeploy your service by itself.
- Because environments are separate,
${{Postgres.DATABASE_URL}}instagingpoints at thestagingdatabase.
Shared variables
Each environment has shared variables (the Shared variables section of the Variables tab). A shared variable is not set on any service by itself; services opt in with ${{shared.NAME}}. When a shared variable changes, running services that reference it are redeployed.
Automatic variables
Fjordrun sets these on every service. You can use them directly in your app or in references:
| Variable | Value |
|---|---|
PORT | The service's port (8080 by default for web services). Listen on it. |
FJORDRUN_PRIVATE_DOMAIN | The private hostname, <service>.<environment>.internal. |
FJORDRUN_PUBLIC_DOMAIN | The service's public hostname (the first active domain), or empty if it has none. |
FJORDRUN_ENVIRONMENT | The environment name, for example production. |
FJORDRUN_SERVICE_NAME | The service name. |
FJORDRUN_PROJECT_NAME | The project name. |
FJORDRUN_SERVICE_ID | The service ID. |
From the CLI
bash
fjordrun vars list # list
fjordrun vars set API_KEY=abc LOG_LEVEL=debug
fjordrun vars unset LOG_LEVELSee the CLI reference.