Service settings

Environment variables: static values, references to other Services, secret() helper, and database reference variables.

Written By Zoro

Last updated 3 days ago

This page migrates the legacy Environment variables guide into the Services IA. You configure variables on App and Docker Services from the Service settings UI.

Types of values

Static values

Fixed strings that stay the same across Deployments.

Example: STRIPE_SECRET_KEY=sk_test_51HxxxxxxEXAMPLE

Dynamic references

Link a variable to another Service or resource so updates propagate when the target changes. Syntax uses double braces with a service slug (or generated name) and variable:

Example: MONGO_URI={{ databases-7cis-marketing-os1g.MONGO_URI }}

(Replace with names from your workspace.)

secret() helper

Generate random secrets at deploy time:

Format: length, then charset string.

Example: PAYLOAD_SECRET={{ secret(64, "abcdefghijklMNOPQRSTUVWXYZ") }}

Combining values

Join static text and references in one variable, for example:

  • url=https://{{ databases-7cis-test-2tiu.DFLOW_PUBLIC_DOMAIN }}
  • DATABASE_HOST={{ databases-7cis-marketing-os1g.MONGO_HOST }}:{{ databases-7cis-marketing-os1g.MONGO_PORT }}

Database reference variables

Database Services expose references you can use from App / Docker Services. Private vs public sets differ; use Expose (or equivalent) on the database Service when you intentionally publish public endpoints.

Private (typical)

DatabaseVariables
MongoDBMONGO_URI, MONGO_HOST, MONGO_PORT, MONGO_USERNAME, MONGO_PASSWORD, MONGO_NAME
PostgreSQLPOSTGRES_URI, POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USERNAME, POSTGRES_PASSWORD, POSTGRES_NAME
MySQLMYSQL_URI, MYSQL_HOST, MYSQL_PORT, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_NAME
MariaDBMARIA_URI, MARIA_HOST, MARIA_PORT, MARIA_USERNAME, MARIA_PASSWORD, MARIA_NAME
RedisREDIS_URI, REDIS_HOST, REDIS_PORT, REDIS_USERNAME, REDIS_PASSWORD, REDIS_NAME

Public (when exposed)

DatabaseVariables
MongoDBMONGO_PUBLIC_URL, MONGO_PUBLIC_HOST, MONGO_PUBLIC_PORT
PostgreSQLPOSTGRES_PUBLIC_URL, POSTGRES_PUBLIC_HOST, POSTGRES_PUBLIC_PORT
MySQLMYSQL_PUBLIC_URL, MYSQL_PUBLIC_HOST, MYSQL_PUBLIC_PORT
MariaDBMARIA_PUBLIC_URL, MARIA_PUBLIC_HOST, MARIA_PUBLIC_PORT
RedisREDIS_PUBLIC_URL, REDIS_PUBLIC_HOST, REDIS_PUBLIC_PORT

Use the database Service Generate / Expose flow in the UI to opt in to public references.

Best practices

  • Prefer references over hard-coded secrets and hostnames.
  • Use secret() for generated credentials.
  • Redeploy or restart after changes so processes pick up new values.
  • Keep naming consistent across Services.
  • Never commit secrets to Git.

Limitations

Environment variables and Volumes for database-type Services are more restricted than for App and Docker Services; follow in-product messages.

Related