TurboPanel Docs
Using TurboPanel

Storage, variables and secrets

Two things a compose document deliberately does not contain: where its data lives, and the values its services read at build and at runtime. Both are properties of the environment and the scopes above it, managed on their own tabs, and referenced — never copied — from the document. This chapter covers the Storage tab, the Variables panels at every scope, secrets, and the {$KEY} reference syntax that ties them into compose.

Storage

The model

A storage entry is one persistent location an environment's service mounts: a named Docker volume, a host directory, or a single file. It belongs to the environment (storage is provisioned on that environment's server), is mounted into one service at a destination path, and carries two policies:

PolicyValuesMeaning
Access modesingle_writer (default) · multi_reader · multi_writerWhether more than one service, or more than one server, may hold it open. A single_writer entry whose primary copy sits on a server other than the one a deploy schedules is refused (storage_location_unavailable).
Retentionretain (default) · deleteWhat happens to a volume's folder when its environment or service is deleted: kept on the server, or removed with it. Docker volumes are not removed by a delete; see below.

Behind an entry are its copies — where the bytes actually are. A copy has a provider (docker for a named volume, path for a host path), a role (primary, replica, scratch, archive) and a state (pending → materializing → ready, or syncing, stale, failed, retiring). One copy is the primary; a scratch copy is never mounted. Most entries have exactly one, on the environment's server.

Add storage

Select the environment and open Storage (from the gear on the Services document, or the surface tab). At project scope the tab stacks one panel per environment.

Name the entry; choose the Kind — Volume, Directory or File — and the Server it lives on.

For a directory or file, give the Host path. A file's content (up to 256 KiB — larger files belong in a volume or a build) can be set through the API; the app form has no field for it.

Pick the Mount service and the Destination path inside it. Two entries cannot mount at the same destination in one service.

Create storage. The mount is live on the next deploy. The app form has no access mode or retention field, so a new entry takes the defaults (single_writer, retain); change them through the API.

Compose-declared volumes: still work exactly as in Compose; the Storage tab is for data the platform should know about — the things a redeploy on another server has to find.

Docker volumes and Destroy. A Destroy keeps every Docker volume on the Storage tab. To delete them, tick Also Delete the Data Volumes when you destroy the environment and type its name; shared, external and in-use volumes still stay. See Destroy and the data volumes.

Reference

FieldValues
kindvolume · directory · file
accessModesingle_writer · multi_reader · multi_writer
retentionretain · delete
copies[].providerdocker · path
copies[].roleprimary · replica · scratch · archive
copies[].statepending · materializing · ready · syncing · stale · failed · retiring
File content≤ 256 KiB
Parentworkspace, project, environment or service — one of them

Volume backups

A storage entry's copy can be backed up on a schedule or on demand, and restored from any of its backups. This is API-only today: the app has no screen for it yet. (Managed databases have the app's Backups tab: see Managed databases.)

What can be backed up. A copy on a server of your own that is either a Docker volume (docker provider), or a host directory (path provider) in a system user's volumes/ folder under /srv/users/ (see Where your files live) or under the server's own default storage directory. Copies on remote providers (NFS, S3 and the like), file and object entries, and copies with no server are refused with backup_target_unsupported. Only organization owners and managers may back up or restore.

How a backup is made. A live archive: the data is read while the app keeps running, so nothing is paused or stopped and nothing is down. A database or other file that is being written at that moment can be captured mid-write, so for data like that prefer a managed database or take the backup while the app is quiet. The server archives the copy in a short-lived helper container with no network access that mounts the data read-only, writes a .tar.gz file under volumes/<copy id>/ in its backup directory (/backup, or the directory set with TURBOPANEL_BACKUP_DIR; the app stores the path relative to that directory), and records its size and SHA-256 checksum. Backups stay on that server's own disk, so they do not protect against losing the server.

All of these are under /api/client/v1/storage/{id}/copies/{copyId}:

RouteWhat it does
GET …/backupsLists the copy's backups, newest first: manual and scheduled, with policyId (null for a manual backup), sizeBytes, checksum and path.
POST …/backupsBack up now. Queues the backup on the copy's server, which must be online; the record appears when it succeeds.
DELETE …/backups/{backupId}Queues removal of the archive; the record goes when it succeeds.
POST …/backups/{backupId}/restoreRestore (below).
GET / POST …/backup-policiesLists or creates schedules for the copy.
PATCH / DELETE …/backup-policies/{policyId}Edits or deletes a schedule. Deleting stops its timer; backups it already made stay on the server.
GET …/backup-policies/{policyId}/runsA schedule's recent runs, newest first (limit 1–100, default 20).

Schedules use the same shape as a managed database's (see Schedules): a name (up to 64 characters), a schedule that is either a preset object ({"preset":"hourly"}, {"preset":"daily","time":"03:00"}, {"preset":"weekly","day":"mon","time":"02:00"}) or cron text in five fields, an optional IANA timezone (server time when left out), retentionKeep (1–100: how many of that schedule's archives to keep) and enabled. A copy can have at most 20 schedules. The server runs them from a timer of its own, even while the control plane is unreachable, and a run missed while the server was off happens once when it is back. A schedule prunes only its own archives. Unlike a new managed database, a volume gets no automatic schedule: you add them.

JSON
{
  "name": "Nightly",
  "schedule": { "preset": "daily", "time": "02:30" },
  "retentionKeep": 14
}

Restore replaces the copy's contents with the backup's. In order:

  1. The server checks that the archive is on that server and that its checksum matches the one recorded. If either check fails, nothing is touched and the apps keep running.
  2. It stops the running containers that mount the copy (and only those). A container that was already stopped stays stopped. If one cannot be stopped, the others are started again and the restore is called off.
  3. It unpacks the archive next to the data first, then swaps: the old contents move aside, the new ones move in, the old ones are deleted. If the swap fails part-way, the old contents are moved back. Files created since the backup are gone; files deleted since it come back. The swap needs room for both the old and the new contents on the same disk.
  4. It starts every container it stopped, even if the restore failed. If one will not start, the restore is reported as failed and names it.

Each affected container is down for its normal stop time (up to about ten seconds) plus the time to unpack: seconds for a small volume, minutes for many gigabytes. Two limits to know: an app that is not a container (for example a native app reading a /srv/users/ folder) keeps running while its files are swapped, and a deploy or restart of the same app during a restore can start a container again part-way through. A copy that has moved to another server fails with not on this host and changes nothing.

Variables

The model

A variable is a key and a value at one scope. Scopes nest, and a service's effective environment is the merge from the outside in:

PLAINTEXT
organization → workspace → project → environment → service → hosting

A key set at a narrower scope overrides the same key set wider. Server-scoped variables are the seventh scope, resolved per server at deploy rather than inherited down the project tree, so a value can differ by host. The app edits three of the scopes today: the project's and the environment's on their Settings tabs (Add Variable), and a hosting row's on the Hosting tab once the row is saved. Organization, workspace, service and server scopes exist in the API (POST /variables with the matching parent id) and resolve in the cascade, but have no app screen yet.

Each variable carries four switches:

SwitchMeaning
SecretThe value is stored sealed and is write-only — the API returns null for it, the app shows a placeholder, and at deploy it travels sealed to the daemon and lands as a file, never in YAML or in the generated .env.
LiteralThe value is used exactly as typed — a $ in it is escaped so Docker Compose does not try to interpolate it. Off, a ${OTHER} inside the value is left for Compose to expand.
For buildPassed as a build argument to services that build an image. Off by default.
For runtimePassed to the running container. On by default.

Keys match [A-Za-z_][A-Za-z0-9_]*. A key a database binding owns (the connection details of a managed database bound to the environment) is locked: it shows under From connected databases, cannot be edited (binding_owned_variable), and cannot be shadowed by a variable of the same name (binding_key_conflict).

Add a variable

Open the Variables panel at the scope the value belongs to — as wide as it applies, as narrow as it must.

Add Variable: key, value, and the four switches. Mark passwords, tokens and keys Secret before saving; a secret cannot be read back, only replaced.

Save. The value reaches every service in scope on its next deploy; the Prepared compose preview shows the generated .env (non-secrets) and the file paths secrets will take.

Referencing variables from compose

Plain Compose ${KEY} works as Docker defines it, against the generated .env. TurboPanel adds one reference form, resolved by the platform before Compose sees the document:

YAML
services:
  api:
    environment:
      DATABASE_URL: "{$DATABASE_URL}"        # nearest scope wins
      REGION: "{$organization.REGION}"       # pinned to one scope
    secrets:
      - source: api_token                    # a secret compiled to a file

{$KEY} takes the effective value from the cascade; {$scope.KEY} (organization, workspace, project, environment, service, hosting, server; org is accepted for organization) pins a scope. A reference to a secret is compiled into a Compose secrets: entry backed by a file the daemon materializes under /run/turbopanel/deployments/<project>/<environment>/secrets/, plus a courtesy <KEY>_FILE variable holding that path. The file is readable by every user inside that one container (so an image that runs as a fixed non-root user can read it) and by no other account on the server. A tool that refuses to read a password or key file other users could read has to copy the file to a private place first (see Generated Config Files). Interpolating a secret directly into a plain field is refused (variable_secret_interpolation), because that would write it into YAML.

Reading a database binding from any variable

A database binding writes its connection details as variables under its own prefix (DATABASE_HOST, DATABASE_PASSWORD and so on; DATABASE is the default prefix). Those names are locked, and an app often wants the same values under other names. Instead of copying them, write a database reference in the value of a variable on the app:

PLAINTEXT
{$db.<prefix>.<field>}

<prefix> is the binding's key prefix exactly as it is stored (DATABASE in {$db.DATABASE.host}), and the binding must belong to the same service. Because a reference reads the binding's own values, it follows a failover, a password rotation or a new organization CA on the next deploy, with nothing to edit.

FieldValueSecret
host, port, name, userThe same values as <PREFIX>_HOST, <PREFIX>_PORT, <PREFIX>_NAME, <PREFIX>_USERNo
passwordThe passwordYes
urlThe full connection URLYes
ssl_modeThe SSL mode as the engine's driver spells it, the same as <PREFIX>_SSL_MODENo
ca_fileThe path of a file that holds the organization CANo
ca_textThe organization CA as textYes
driverpostgres, mysql or mariadbNo
read_splitThe same as <PREFIX>_READ_SPLITNo

Where a reference works:

  • Service and hosting variables, at any scope. Write it in the value of a plain variable. A non-secret field can sit anywhere in the text ({$db.DATABASE.host}:{$db.DATABASE.port}). A secret field (password, url, ca_text) must be the whole value, and the variable then becomes secret.
  • A Compose environment: value. Write {$db.DATABASE.host} as the whole value, the same as any other {$…} reference. A secret field reaches the container as a file, like every secret (see above).
  • A generated config file. In configs.content, a reference works anywhere in the text, secret fields included. See Generated Config Files.

Rules:

  • No secret variables, no build variables. A secret variable is never read for references, so save a reference as a plain variable; a reference to a secret field stays secret. A variable used for builds cannot hold one either, because database settings reach the running app only.
  • Only db references expand in a stored value. {$KEY} and {$scope.KEY} in a variable's value stay literal text.
  • A literal {$db.. Write {$$db. and the app gets the literal text {$db.. Text a reference inserts is used as it is and never scanned again.
  • Fields a kind of app cannot have. On a PHP site the CA comes as a file, so ca_text is refused, and ca_file must be the whole value (the daemon fills in the path on the server). A Node app gets the CA as text, so ca_file is refused for it.
  • A missing connection. If the service has no binding with that prefix (or the binding has no value for the field), the answer depends on where the variable is set. On the service itself or one of its hostnames, the deploy is refused (variable_unresolved). Set higher up (organization, workspace, project, environment or server), the variable is left out for that service and the deploy shows a warning (variable_db_ref_unresolved) naming the service, the variable and the reference, never a value.

A reference that is written wrongly (an unknown field, a secret field inside longer text, a reference inside a secret variable, or one on a build variable) is refused when you save the variable. A secret field embedded in longer text that slips through is refused at deploy (variable_ref_invalid).

Variable Names (presets)

Many apps read their database settings from fixed names. In the web interface, a binding has a Variable Names choice, and Change Names edits it on an existing binding. The binding always sets its own prefixed names; the preset adds a second set of names the app expects, listed under Also Sets before you save. A preset's values come from the binding's own values, the same ones a reference reads, so they follow a failover, a password rotation or a new CA at the next deploy.

A service can have one binding with a preset; a second one fails with binding_engine_defaults_in_use. A preset must fit the engine (binding_preset_engine_mismatch), and a request cannot name a preset and the older emitEngineDefaults flag together (binding_preset_conflict).

PresetEnginesNames it sets
Plain PostgreSQLPostgreSQLPGHOST, PGPORT, PGDATABASE, PGUSER, PGPASSWORD (PGPASSWORD_FILE in a container), PGSSLMODE, and PGSSLROOTCERT in the verify-ca and verify-full modes
Plain MySQLMySQL, MariaDBMYSQL_HOST, MYSQL_PORT, MYSQL_DATABASE, MYSQL_USER, MYSQL_PASSWORD
LaravelAllDB_CONNECTION (pgsql, mysql or mariadb), DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD, DB_URL; PostgreSQL adds DB_SSLMODE, MySQL and MariaDB add MYSQL_ATTR_SSL_CA
WordPressMySQL, MariaDBDB_HOST (as host:port), DB_USER, DB_PASSWORD, DB_NAME
MetabaseAllMB_DB_TYPE (postgres, or mysql for both MySQL engines), MB_DB_HOST, MB_DB_PORT, MB_DB_DBNAME, MB_DB_USER, MB_DB_PASS
Uptime KumaMySQL, MariaDBUPTIME_KUMA_DB_TYPE (mariadb), UPTIME_KUMA_DB_HOSTNAME, UPTIME_KUMA_DB_PORT, UPTIME_KUMA_DB_NAME, UPTIME_KUMA_DB_USERNAME, UPTIME_KUMA_DB_PASSWORD, UPTIME_KUMA_DB_SSL (true unless the SSL mode is disable), UPTIME_KUMA_DB_CA (the CA as text; not on a PHP site)

An entry whose field the app's kind cannot have is left out rather than failing: ca_file on a Node app, or the CA as text on a PHP site. A binding made before presets existed keeps its names. If it had the engine default names switched on, it reads as the Plain preset for its engine and sets exactly what it did, plus PGSSLROOTCERT on a PostgreSQL container or site in a verify mode.

In a container, secret names arrive as files like every binding secret, so a Laravel container gets DB_PASSWORD_FILE rather than DB_PASSWORD, and Laravel does not read _FILE names. Metabase does: it reads MB_DB_USER_FILE and MB_DB_PASS_FILE (see "Use Docker Secrets" on Metabase's Docker page). A PHP site or a Node app gets the plain names.

PostgreSQL Passwords in Containers

A container connected to a managed PostgreSQL database gets the password only as a file, in PGPASSWORD_FILE (the path of the file), and never as a plain PGPASSWORD. This is on purpose, so the password is not in the container's environment. Plain psql and any image that does not read _FILE forms need it read from the file, for example:

Terminal
PGPASSWORD="$(cat "$PGPASSWORD_FILE")" psql

Once you copy the password out of the file into a variable or a command line, as in that example, anything that logs the command or its environment shows the password.

SSL mode and the CA file

A binding also sets two names that carry the connection's TLS settings (see Managed databases):

  • <PREFIX>_SSL_MODE, the SSL mode as the driver spells it, for every kind of app.
  • <PREFIX>_CA_FILE, the path of a file that holds the organization CA. A container gets /run/secrets/<PREFIX>_CA_CERT, a mount of the same certificate that <PREFIX>_CA_CERT carries as text. A PHP site gets a file the daemon writes in the site's .turbopanel-hosting folder.

In the verify-ca and verify-full modes, a PostgreSQL connection string carries sslrootcert=<path to the CA file>, so a client that reads only the URL still checks the right root. A container's URL has it from the control plane. A PHP site's URL has it added by the daemon on the server, which needs a daemon that is updated; on an older one the URL has no sslrootcert, as before. A MySQL or MariaDB URL is unchanged in every mode, and so is a Node app's.

Generated Config Files

A configs: entry with content becomes a file whose text may use the same references anywhere in it, secrets included. Use it for a file an image reads at start, such as a server list or a password file:

YAML
configs:
  pgadmin_servers:
    content: |
      {"Servers": {"1": {"Name": "Cluster", "Group": "Servers",
        "Host": "{$DB_HOST}", "Port": {$DB_PORT}, "MaintenanceDB": "{$DB_NAME}",
        "Username": "{$DB_USER}", "PassFile": "/pgpass"}}}
  pgadmin_pgpass:
    content: |
      {$DB_HOST}:{$DB_PORT}:*:{$DB_USER}:{$DB_PASSWORD}
services:
  pgadmin:
    environment:
      PGPASS_FILE: /pgadmin4/pgpass
    configs:
      - source: pgadmin_servers
        target: /pgadmin4/servers.json
      - source: pgadmin_pgpass
        target: /pgadmin4/pgpass
  • Per service. Each service that uses a config gets its own copy, mounted read-only at its target (without one, Compose uses /<name>). Each service gets its own copy, and a service cannot name another service's generated config.
  • Secrets stay sealed. The control plane never decrypts a secret for a file. The file is put together on the server by the daemon and lives only on memory-backed storage there, in a folder only TurboPanel's account can open. Every user inside that one container can read it. Secret values are masked in deploy logs, and the deploy preview shows a secret slot as {$KEY}, never a value.
  • Dollar signs. Write a literal $ as $$ ($$cfg['Servers'][$$i] for a PHP file) and a literal {$name} as {$$name}. On a server whose daemon is updated, a plain Compose ${X} or $X in the text is refused (config_interpolation); on an older daemon, text with no {$ is passed to Compose unchanged, so Compose reads ${X} as it always has. A value inserted from a variable is used as it is and is never scanned again.
  • Owner and mode. uid, gid and mode on a config entry are ignored with a warning: the file is read-only and readable by every user in the container.
  • Limits. 64 KiB of text per file, 16 files per service and 256 KiB per deploy. A name may not end in .tmp.
  • Older daemons. A config that uses {$…} values goes only to a server whose daemon is updated; otherwise the deploy is refused (config_files_need_daemon_update) and the answer names a server that needs the update. The deploy preview gives the same answer. A config with no {$…} value is passed to Compose unchanged, as before.
  • Tools that refuse readable key files. libpq ignores a password file other users could read, so point it at a copy: the pgAdmin container documents PGPASS_FILE, which it copies into the container on startup and uses as its password file, so the example mounts the generated file and points pgAdmin at it. A tool that does not copy the file cannot be pointed straight at a generated file.

Variables on a Node app

A Node app (How is this served? → Node app) is run by the server's service manager, not by Docker, so a compose environment: block never reaches it. TurboPanel passes its variables a different way, and shows exactly what the process will get.

RuleMeaning
Plain variablesEvery variable with For runtime on is passed. For build only is never passed to the running process.
SecretsPassed when the app's environment: references them with {$KEY}, when a database binding owns them, or when the secret was set on the app itself (service or hostname scope). A secret set higher up — organization, workspace, project, environment or server — is not passed until the app asks for it, so a credential set for a whole organization never lands in an app that did not ask.
Names TurboPanel sets itselfHOST, NODE_ENV, PORT, PATH, HOME, TMPDIR, XDG_CACHE_HOME, COREPACK_HOME and COREPACK_ENABLE_DOWNLOAD_PROMPT are never taken from your variables.
Names and values the server refusesA name that is not [A-Za-z_][A-Za-z0-9_]* or is over 128 characters, a value over 64 KiB or holding a null character, and anything past 256 variables are held back and listed with the reason. They do not fail the deploy.
ValuePassed as typed: trimmed, not Compose-escaped, and a ${...} inside it is not expanded.

See what the app will get. Open Preview ▾ → Prepared compose (see Preview). Each Node app has a Node app variables block with one line per variable: NAME = value (where it was set). A secret shows as hidden (secret). The place it was set is one of organization variable, workspace variable, project variable, environment variable, service variable, hostname variable, server variable, managed database or set by TurboPanel. A variable that is set but not passed says why, for example:

  • not passed: it was set above this app, so the app has to ask for it, with the hint to add {$NAME} to the app's environment;
  • not passed: TurboPanel sets this one itself;
  • not passed: not a valid variable name, the value is too long or holds a null character, or an app can take at most 256 variables.

The same list is nativeAppVariables in the answer of GET /environments/:id/deploy-preview: one list per Node app, with the value null for a secret.

On the server. The values are written to a private file that only the server's root account can read, and the app's service unit loads it. The app gets the values in its environment but cannot read the file. A secret is never in the unit, the command line or the deploy transcript. A changed value reaches the process with the restart every deploy already does, and an app with no variables has no file. If a secret an app references has no stored value, the deploy fails and names the variable, never its value.

Errors

CodeStatusMeaning
storage_content_too_large400File content exceeds 256 KiB.
principal_project_mismatch400The entry's system user belongs to another project.
mount_destination_in_use409Another entry already mounts at that destination in the service.
copy_primary_exists, copy_server_provider_exists409The entry already has a primary copy, or a copy on that server with that provider.
scratch_copy_not_mountable409A scratch copy cannot be mounted.
conflict409A storage write hit a uniqueness rule not otherwise classified; retry with a different name or destination.
storage_location_unavailable422 (deploy)The entry's primary copy is on another server and its access mode forbids that; move the copy or relax the mode.
backup_target_unsupported400The copy cannot be backed up: a remote provider, a file or object entry, or no server.
backup_policy_invalid, backup_schedule_invalid, backup_timezone_invalid400A schedule field, the schedule or the timezone is wrong; the response says which.
backup_policy_limit409The copy already has 20 schedules.
backup_policy_not_found, backup_not_found404No schedule or backup with that id on this copy.
server_placement_required, server_offline409The copy has no server, or its server is offline: a manual backup, delete or restore needs it online.
binding_key_conflict409The key collides with one a database binding owns.
binding_owned_variable409The variable is written by a binding; sever the binding to change it.
variable_unresolved422 (deploy)A {$KEY} reference has no value at any scope in reach, or a {$db.…} reference set on the service or its hostname has no matching binding or field.
variable_ref_invalid422 (deploy)A malformed reference, an unknown scope, or a secret database field inside longer text.
variable_db_ref_unresolvedwarning (deploy)A variable set above the service refers to a database connection the service does not have; the variable is left out for it.
binding_preset_conflict, binding_preset_engine_mismatch, binding_engine_defaults_in_use400, 400, 409A binding named a preset and the older flag together; the preset does not fit the database engine; the service already has a binding with a preset.
variable_secret_interpolation422 (deploy)A secret referenced in a plain field; use a secrets: entry.
config_interpolation422 (deploy)A config's text uses Compose ${X} or $X; use {$X} for a variable and $$ for a literal $.
config_file_invalid422 (deploy)A config name ends in .tmp, produces a file name another config uses, would replace an existing top-level config, or is over the size limits.
config_file_shared422 (deploy)A service names a generated config that belongs to another service.
config_files_need_daemon_update409 (deploy)A config uses {$…} values and a target server's daemon is not updated yet; the response names a server that needs the update. The deploy preview returns it too.
Edit on GitHub

Last updated on

On this page