Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Deployment

Running an application in production: a release binary, the files beside it, secrets from the environment, and a reverse proxy in front.

Build the binary

cargo build --release
# target/release/acme

Run it from a directory holding config/.

Ship the files

PathDescription
acmeThe release binary. Plugins are compiled into it; nothing of plugins/ ships.
config/default.tomlThe committed defaults.
config/production.tomlOptional. Read when APP_ENV=production.
storage/Writable by the process. Empty on the first start.

config/local.toml stays on the development machine. Secrets travel as environment variables.

Set secrets in the environment

export APP_ENV=production
export LAT__DATABASE__URL="postgres://acme:secret@db.internal/acme"
export LAT__APP__KEY="$(lat key generate --print | head -1)"
./acme
VariableSets
APP_ENVWhich config/<APP_ENV>.toml layer is read. Default development.
<PREFIX>__DATABASE__URLdatabase.url.
<PREFIX>__APP__KEYapp.key, the key everything is sealed and signed under. Set it in production; several instances share it. See Encryption and Signing.
<PREFIX>__SECTION__KEYAny other key. The prefix is app.env_prefix, LAT by default.

Sit behind a proxy

# config/production.toml
[app]
url = "https://acme.example"

[server]
listen = "127.0.0.1:8080"

[backend]
secure_cookie = true
trusted_proxies = ["127.0.0.1/32"]
KeyDescription
app.urlThe public origin absolute links build on.
backend.secure_cookieSets the Secure flag on cookies. true behind HTTPS.
backend.trusted_proxiesCIDR ranges whose X-Forwarded-For is read. The proxy’s own network.
server {
    listen 443 ssl;
    server_name acme.example;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Gate the deploy

lat doctor
CheckPasses when
Configuration loadsEvery layer parses and database.url is present.
Timezone is validbackend.timezone is an IANA name.
storage/ is writableThe process can write the application’s storage/.
Database is reachableA connection opens.
Tables existThe framework’s tables are migrated.
plugins-manifest is in syncThe list and the generated crate agree.
Descriptor files parseEvery YAML descriptor loads.

Exits non-zero on any failure. Run it from the application directory, or pass --database-url.

Recover access

lat admin create ops --email ops@acme.example --first-name Ops --generate
lat admin reset-password editor --generate
lat admin unlock editor
lat admin purge
CommandDescription
createA new superuser. --generate prints a strong password.
reset-passwordA new password for an existing user.
unlockClears a user’s failed sign-in lockout.
purgeRemoves expired sessions and stay-signed-in credentials.

Outside the application directory, pass --database-url or set DATABASE_URL.