Environment variables

sg reads three settings from the environment. Everything else comes from your specs.

VariableDefaultMeaningRule
SG_ENVdevelopmentNamed environmentMust not be empty
SG_LOG_LEVELinfoLog detaildebug, info, warn or error
SG_STATE_DIR.sgWhere the ledger livesMust 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.yaml uses ~/estates/lab/.sg/state.db wherever 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 fieldDefault nameRead byWhen it's missing
bootstrap.tailscale.auth_key_envTS_AUTHKEYsg machine plan and createRefuses, naming the variable
services[].admin_password_env(required, no default)sg application plan and deployRefuses with secret is unavailable: <VAR>
services[].admin_user_env(optional)sg application plan and deployFalls 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:

VariableDefaultMeaning
SG_INSTALL_DIR~/.local/binWhere sg is installed
SG_VERSIONlatestRelease tag to install, e.g. v0.1.0-dev