Skip to content

Variables: values every stack may use

Several applications on one server often share a value: the password of the shared database, an API key, the address of the mail server, your company name. Without global variables you type that value into every stack and change it in every stack. With them you set it once, on the Variables page, and every stack that uses it picks it up at its next deploy.

The Variables page

Every line is one variable:

  • Name: letters, digits and underscores, by convention in CAPITALS, such as DB_PASSWORD or SMTP_HOST. The name is what a stack refers to. It cannot be changed afterwards (remove and add again).
  • Value: one line of text. Spaces, quotes and $ are fine; the value reaches the containers exactly as you typed it.
  • Hidden: for passwords, keys and tokens. A hidden value is masked on the page (the eye button shows it) and is never returned by the API, the command-line tool or a connected assistant. They can make a stack use it; they cannot read it. Hidden is also one-way outside the portal: through the API, the command-line tool or an assistant a hidden variable can only become visible again together with a new value (without one the change is refused), and a restored earlier version keeps hidden variables hidden. In the portal you simply clear the checkbox.
  • Description: optional, for yourself and your colleagues.
  • Used by: the stacks that take this variable right now.

Add a variable opens the form; the pencil edits a variable, the bin removes it. Everything you change is kept in the History tab: every change saves the whole list as a version, and Restore puts an earlier version back (as a new version, so that too can be undone).

There is one rule: a variable the stack does not fill in itself comes from the global list.

  • On the stack’s Settings tab, leave the field with that name empty. The field says so: “Empty = the global variable DB_PASSWORD”. A value you do type there wins, for that stack only.
  • In a compose file, refer to it as ${DB_PASSWORD}, exactly like a variable from the stack’s own .env. Nothing in the file says where the value comes from.
  • When you create a new stack from a template, a field whose name exists as a global variable starts empty (no generated password); the stack takes the shared one.

The order is always: the stack’s own value, then the global variable, then the default in the compose file.

Every server comes with HD Services’ mail relay for your applications, as five variables that HD Services adds and keeps up to date:

Variable Value
SMTP_HOST smtp2.mail3000.nl
SMTP_PORT 2527
SMTP_USERNAME hddeploy@mail3000.nl
SMTP_PASSWORD hidden, set by HD Services
SMTP_SENDER hddeploy@mail3000.nl

An application that sends mail (password resets, invitations, notifications, a contact form) uses these instead of a mail server of its own. Templates whose mail fields have these names take them when you leave the fields empty. In a compose file you map them to the names the application reads, for example MAIL_HOST: ${SMTP_HOST}. Configure the application for STARTTLS on port 2527 (not “SSL/TLS”) and the LOGIN sign-in method (the relay does not offer PLAIN), and send from SMTP_SENDER. Sending from an address of your own domain (noreply@yourcompany.nl) works too, once HD Services has added the relay to that domain’s SPF record: ask the helpdesk before you switch, or receivers may treat the mail as spam.

They are ordinary variables: you may change or remove them. A variable you changed or removed stays as you left it; one you never touched follows HD Services when it changes the relay or its password (the stacks that use it take the new value at their next deploy). If SMTP_PASSWORD is missing from your list, HD Services has not set it on this server yet: ask the helpdesk.

list_variables shows the list (never the hidden values), set_variable adds or changes a variable, remove_variable removes one. The scopes are variables.read and variables.manage; both are in the recommended set for assistants. An assistant will suggest a global variable when you repeat a value across stacks or ask to change one “everywhere”. Over the REST API: GET/PUT/DELETE /variables/{name}. With the command-line tool: hddeploy variable list|set|remove|history|restore.

Prompts that work: “Put the database password in a hidden global variable DB_PASSWORD and make stacks shop and intranet use it.” - “Change SMTP_HOST to smtp.example.nl everywhere and deploy the stacks that use it.”