Skip to main content

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.

tip

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.

ConfigurationBuild phaseRunning container
Build + Runtime (default)AvailableAvailable
Build onlyAvailableNot available
Runtime onlyNot availableAvailable

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:

  1. Team Based — Set on the Team page, use with {{team.NODE_ENV}}
  2. Project Based — Set on the Projects page, use with {{project.NODE_ENV}}
  3. Environment Based — Set on the Environments page, 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 application
  • COOLIFY_URL — URL(s) of the application
  • COOLIFY_BRANCH — Branch name of the source code
  • COOLIFY_RESOURCE_UUID — Unique resource identifier
  • COOLIFY_CONTAINER_NAME — Name of the container
  • SOURCE_COMMIT — Commit hash of the source code
  • PORT — If not set, defaults to the first port in Port Exposes
  • HOST — If not set, defaults to 0.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:

TypeWhat 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.