Environment Variables
You can define environment variables for your resources, and they will be available in your application.
Preview Deployments can have different environment variables, so you can test your application as a staging environment.
Normal View vs Developer View
Normal View
The default view displays each environment variable as an individual form card with editable key and value fields, along with checkboxes for options like Build Variable, Multiline, and Literal.
Developer View
The Developer view provides a plain-text editor where all environment variables are displayed in .env file format (KEY=VALUE, one per line). Useful for bulk editing or pasting from an existing .env file.
Lines starting with # are treated as comments and ignored when saving.
Build Time vs Runtime Variables
Every environment variable has two independent flags: Build Variable and Runtime Variable. Both are enabled by default.
| Configuration | Build phase | Running container |
|---|---|---|
| Build + Runtime (default) | Available | Available |
| Build only | Available | Not available |
| Runtime only | Not available | Available |
Build Variables
Build variables are injected during the image build process. For Dockerfile deployments, they are added as ARG instructions. For Docker Compose and Nixpacks/Buildpack deployments, they are passed via --env-file.
Runtime Variables
Runtime variables are available inside the running container. After the build completes, the platform writes a .env file containing all runtime-enabled variables.
Docker Build Secrets
For sensitive values, you can enable Use Docker Build Secrets which uses Docker BuildKit to temporarily mount secrets during build steps, leaving no trace in the final image.
Multiline Variables
Enable the Multiline checkbox for values spanning multiple lines, such as SSH keys, TLS certificates, or multi-line config files.
Literal Variables
Enable the Literal checkbox to prevent variable interpolation. Useful for values containing $ characters that should not be interpreted as variable references.
Shared Variables
You can have 3 types of shared variables:
- Team Based — Set on the
Teampage, use with{{team.NODE_ENV}} - Project Based — Set on the
Projectspage, use with{{project.NODE_ENV}} - Environment Based — Set on the
Environmentspage, use with{{environment.NODE_ENV}}
Predefined Variables
The platform predefines some variables for you:
Application Variables
COOLIFY_FQDN— Fully qualified domain name(s) of the applicationCOOLIFY_URL— URL(s) of the applicationCOOLIFY_BRANCH— Branch name of the source codeCOOLIFY_RESOURCE_UUID— Unique resource identifierCOOLIFY_CONTAINER_NAME— Name of the containerSOURCE_COMMIT— Commit hash of the source codePORT— If not set, defaults to the first port inPort ExposesHOST— If not set, defaults to0.0.0.0
Magic Environment Variables
For Docker Compose / Service Stack deployments, the platform can auto-generate dynamic values using the SERVICE_<TYPE>_<IDENTIFIER> syntax:
| Type | What it generates |
|---|---|
SERVICE_URL_<ID> | A URL based on your wildcard domain |
SERVICE_FQDN_<ID> | The FQDN portion of the generated URL |
SERVICE_USER_<ID> | A random username string |
SERVICE_PASSWORD_<ID> | A random password |
SERVICE_BASE64_<ID> | A random base64 string |
Generated values are reusable across services and persist between deployments.