Run /
Inject runtime variables
You can set runtime variables (ENV) to be passed to the Docker container at runtime. You can set runtime variables in individual resources, or create a secret group so that multiple resources in a project can inherit the same secrets.
You can also upload secret files to make certificates, configuration files, and other data available in your containers.
Runtime variables can be set as key-value pairs, or as JSON in the following format:
{
"KEY_1": "value1",
"KEY_2": "value2"
}
An .env
file can also be uploaded and edited using the following format:
KEY_1=value1
KEY_2=value2
Access environment variables in your code
Your runtime variables can be accessed via the process environment, for example in a Node environment a variable set as ENV_VALUE=Northflank
can be accessed within the container by referring to process.env.ENV_VALUE
.
Runtime environment | Environment variable accessor | Required import |
---|---|---|
Node | process.env.ENV_KEY | none |
Deno | Deno.env.get("ENV_KEY") | none |
Bun | Bun.env.ENV_KEY OR process.env.ENV_KEY | none |
Python | os.environ.get("ENV_KEY") | import os |
Java | System.getenv("ENV_KEY") | none |
Kotlin | System.getenv("ENV_KEY") | none |
Ruby on Rails | ENV["ENV_KEY"] | none |
Rust | env::var("ENV_KEY") | use std::env |
Go | os.Getenv("ENV_KEY") | import ( "os" ) |
C# / .NET | Environment.GetEnvironmentVariable("ENV_KEY") | using System; |
C++ | std::getenv("ENV_KEY") | #include <cstdlib> |
C | getenv("ENV_KEY") | #include <stdlib.h> |
PHP | .$_ENV["ENV_KEY"] | none |
Lua | os.getenv("ENV_KEY") | none |
Shell / Bash | ${ENV_KEY} | none |
PowerShell | $Env:ENV_KEY OR [Environment]::GetEnvironmentVariable('ENV_KEY') | none |
Add a secret file to a deployment
You can include secret files which can be accessed in your container's file system. This can be useful to provide certificates, secrets, or configuration files that must are required by your application, but which should not be included in your repository.
To add a secret file, paste or upload the content in the secret file editor on the environment page of a deployment service, combined service, or a job. You can also upload secret files to secret groups to make them available to multiple resources in the same project.
Next steps
Inject secrets
Set build arguments and inject runtime variables into running deployments.
Manage groups of secrets
Create and manage groups of secrets that can be inherited throughout an entire project or by specific services and jobs.
Upload a secret file
Add secret files that will be mounted in your container.