Environment variables
sg reads three settings from the environment. Everything else comes from your specs.
| Variable | Default | Meaning | Rule |
|---|---|---|---|
SG_ENV | development | Named environment | Must not be empty |
SG_LOG_LEVEL | info | Log detail | debug, info, warn or error |
SG_STATE_DIR | .sg | Where the ledger lives | Must not be empty |
A bad value stops sg before any command runs:
sg: loading configuration: SG_LOG_LEVEL must be one of debug, info, warn, error
SG_STATE_DIR
The ledger is <SG_STATE_DIR>/state.db. A relative value resolves against:
- the spec file's directory for CLI commands, so
sg machine plan --config ~/estates/lab/node-a.yamluses~/estates/lab/.sg/state.dbwherever you run it from; - the launch directory for
sg panel.
An absolute value is used as is. Keep every spec for one estate pointing at the same ledger.
Secrets your specs name
Specs never hold secrets. They hold the name of a variable, and sg reads it at run time.
| Spec field | Default name | Read by | When it's missing |
|---|---|---|---|
bootstrap.tailscale.auth_key_env | TS_AUTHKEY | sg machine plan and create | Refuses, naming the variable |
services[].admin_password_env | (required, no default) | sg application plan and deploy | Refuses with secret is unavailable: <VAR> |
services[].admin_user_env | (optional) | sg application plan and deploy | Falls back to postgres or default |
Errors name the variable and never print its value. Export secrets in the shell that runs sg, from your password manager rather than your shell history where you can:
export TS_AUTHKEY="$(op read 'op://infra/tailscale/auth-key')"
export SG_PG_ADMIN_PASSWORD="$(op read 'op://infra/shop-db/password')"
Installer variables
Read by install.sh only:
| Variable | Default | Meaning |
|---|---|---|
SG_INSTALL_DIR | ~/.local/bin | Where sg is installed |
SG_VERSION | latest | Release tag to install, e.g. v0.1.0-dev |