Skip to content

Environment Variables ​

Set variables when you add a service, or later under the service's Variable tab. Variables are read when the service starts, so after you save changed ones the console offers Restart: the service starts again with the image it runs, without a build. A variable its build reads (a build argument references it, or it has a public front-end name such as NEXT_PUBLIC_* or VITE_*) is part of the image, so it, and any change besides variables, takes a redeploy; the console offers that instead. Other services that reference a changed shared variable keep the old value until they restart too. You can save them while a deployment runs; a deploy you start then waits for it.

Raw editing ​

Click Edit Raw Variables to paste .env-style lines:

sh
NODE_ENV=production
API_URL="https://api.example.com"
# comments and blank lines are ignored

Built-in variables ​

Every service gets these, which you can reference in your own values with ${NAME}:

VariableValue
PORTThe service's first port
<PORT>_PORTEach port by its name, such as WEB_PORT
ZENAVO_<PORT>_DOMAINThe first domain bound to that port, such as ZENAVO_WEB_DOMAIN
ZENAVO_<PORT>_URLhttps:// plus that domain
CONTAINER_HOSTNAMEThe service's private hostname, e.g. postgresql; use ${CONTAINER_HOSTNAME}.zenavo.internal for its private address

Sharing between services ​

A service can expose some of its variables to the rest of the project; databases do this for their connection details (Databases). Other services then reference them as ${NAME}.

Generated passwords ​

Every new service gets a PASSWORD variable holding a random password: 43 letters, digits, - and _, generated when the service is first saved. It is an ordinary variable, hidden until you show it, and you can change or delete it. A PASSWORD you set yourself is kept, and one you delete is not added back. Services created before Zenavo did this have none; add PASSWORD with the value ${PASSWORD} to generate one.

Elsewhere in the service, ${PASSWORD} refers to that variable, as in POSTGRES_PASSWORD=${PASSWORD}, so the two always agree. Changing PASSWORD later does not change a password a database has already been set up with.

PASSWORD itself cannot be shared, because every service has one. To give another service the password, share a variable with a name of its own set to ${PASSWORD}, such as DB_PASSWORD, and reference ${DB_PASSWORD} from the other service.

In a service without a PASSWORD variable, ${PASSWORD} becomes a random password the first time the project is saved, and stays the same afterwards.

Generated values in a set format ​

When an app needs a key in a particular format, such as a 64-digit hex key, write ${SECRET:<format>:<length>} as the value or part of it:

ValueGeneratesSame as
${SECRET:hex:32}32 random bytes as 64 hex digitsopenssl rand -hex 32
${SECRET:base64:32}32 random bytes in base64openssl rand -base64 32
${SECRET:base64url:32}32 random bytes in URL-safe base64, without =
${SECRET:alnum:40}40 letters and digits
${SECRET:uuid}A random UUIDuuidgen

hex, base64 and base64url take a number of bytes, alnum a number of characters, from 8 to 512. Each one is generated once, when the project is saved, and then kept as the variable's value; two in the same service get different values. To use the same value in another service, share the variable that holds it. A malformed one, such as ${SECRET:hex:4}, is refused with the reason when you save. ${SECRET} on its own is still a reference to a variable named SECRET.

Secrets ​

Variable values are encrypted at rest, hidden from team viewers, and redacted from build and runtime logs.