Variables in the file
The env fields of a service in clusterz.yaml, where a value comes from, and when a deploy is refused.
Each entry of a service's env is one environment variable. Only key is required.
| Field | What it does |
|---|---|
services[].env | The service's variables. |
services[].env[].key | The variable's name: letters, digits and underscores, not starting with a digit. Each name appears once. |
services[].env[].value | A fixed value. It is set again on every deploy, so the file owns it. A secret does not take a value in the file: set it with cluz env set. |
services[].env[].generate | A random value of 8 to 128 characters, made once and kept. It is a secret. |
services[].env[].from_service | The address of another service of the same file: the app's address for the web, a public api's own address once it resolves, else the service's name and port on the app's network, like http://api:8080. It cannot name the service itself, nor a worker, which listens on no port. |
services[].env[].from_database | The connection string of a database of the same file, under this variable's name, like REPORTS_URL, for a service that is not in that database's for. |
services[].env[].required | A deploy is refused until the variable has a value, which you give in the form or with cluz up --set KEY=VALUE for the web (--set api.KEY=VALUE for another service, and for every service of an app with no web). |
services[].env[].secret | The value is kept encrypted and never shown again. |
services[].env[].at_build | The variable is available to the build as well as to the running service. |
One source for a value
A variable sets at most one of value, generate, from_service and from_database. With none of them, the variable is the team's to set. A variable that the file gives a value needs no check, so required is refused beside any of them.
Variables a browser reads
Next.js, Vite and other frameworks build variables whose names start with NEXT_PUBLIC_, VITE_, REACT_APP_, NUXT_PUBLIC_, PUBLIC_, EXPO_PUBLIC_ or GATSBY_ into the code a browser downloads. A browser cannot reach a private api, so such a variable cannot take from_service of one. Give the api public: true, or call it from the web's own server.
Environment and secrets explains how the values reach the app.