Overview
TrailBase uses a combination of configuration files, environment variables, and CLI flags to manage settings. Configuration is stored in the data directory (default:./traildepot/) using protobuf text format.
Configuration Files
config.textproto
The main configuration file located at<data-dir>/config.textproto. This file stores non-sensitive configuration in a human-readable protobuf text format.
If
config.textproto doesn’t exist when TrailBase starts, it will be automatically created with default values.<data-dir>/config.textproto
Example:
secrets.textproto
Sensitive configuration is automatically extracted and stored in<data-dir>/secrets/secrets.textproto. This file contains secrets that are referenced in config.textproto using the <REDACTED> placeholder.
Location: <data-dir>/secrets/secrets.textproto
Example:
Configuration Hierarchy
Configuration is resolved in the following order (later sources override earlier ones):- Base configuration -
config.textproto - Secrets -
secrets.textproto(merged into fields marked as<REDACTED>) - Environment variables -
TRAIL_*prefixed variables - CLI flags - Command-line arguments
Data Directory Structure
When TrailBase initializes, it creates the following directory structure:Environment Variables
Configuration Environment Variables
All configuration fields can be overridden using environment variables with theTRAIL_ prefix. The naming convention follows the configuration structure:
Format: TRAIL_<SECTION>_<FIELD>
CLI Environment Variables
CLI options can also be set via environment variables:Configuration Sections
Server Configuration
Application name displayed in UI and emails. Must contain only alphanumeric characters, spaces, or
_, -, ..Environment variable: TRAIL_SERVER_APPLICATION_NAMEPublic site URL. Required for OAuth redirects and email links.Environment variable:
TRAIL_SERVER_SITE_URLLogs retention period in seconds. Default is 7 days (604800 seconds).Environment variable:
TRAIL_SERVER_LOGS_RETENTION_SECAuth Configuration
Authentication token time-to-live in seconds. Default is 1 hour (3600 seconds) in production, 2 minutes in debug builds.Environment variable:
TRAIL_AUTH_AUTH_TOKEN_TTL_SECRefresh token time-to-live in seconds. Default is 30 days (2592000 seconds).Environment variable:
TRAIL_AUTH_REFRESH_TOKEN_TTL_SECMap of OAuth provider configurations. Keys are provider names, values are provider configurations.
OAuth provider type:
OAUTH_PROVIDER_ID_GOOGLE- Google OAuthOAUTH_PROVIDER_ID_GITHUB- GitHub OAuthOIDC0- Generic OpenID Connect
OAuth client ID from the provider.Environment variable:
TRAIL_AUTH_OAUTH_PROVIDERS_<PROVIDER>_CLIENT_IDOAuth client secret from the provider. Automatically moved to secrets vault.Environment variable:
TRAIL_AUTH_OAUTH_PROVIDERS_<PROVIDER>_CLIENT_SECRETAuthorization URL (required for OIDC0 provider).Environment variable:
TRAIL_AUTH_OAUTH_PROVIDERS_<PROVIDER>_AUTH_URLToken exchange URL (required for OIDC0 provider).Environment variable:
TRAIL_AUTH_OAUTH_PROVIDERS_<PROVIDER>_TOKEN_URLUser info API URL (required for OIDC0 provider).Environment variable:
TRAIL_AUTH_OAUTH_PROVIDERS_<PROVIDER>_USER_API_URLEmail Configuration
SMTP server hostname. If not provided, TrailBase falls back to system’s
sendmail.Environment variable: TRAIL_EMAIL_SMTP_HOSTSMTP server port (typically 587 for STARTTLS, 465 for SSL).Environment variable:
TRAIL_EMAIL_SMTP_PORTSMTP authentication username.Environment variable:
TRAIL_EMAIL_SMTP_USERNAMESMTP authentication password. Automatically moved to secrets vault.Environment variable:
TRAIL_EMAIL_SMTP_PASSWORDSMTP encryption method:
SMTP_ENCRYPTION_NONE(0) - No encryptionSMTP_ENCRYPTION_STARTTLS(1) - STARTTLSSMTP_ENCRYPTION_SSL(2) - SSL/TLS
TRAIL_EMAIL_SMTP_ENCRYPTIONEmail address to use as sender. If not set, defaults to
noreply@<host>.Environment variable: TRAIL_EMAIL_SENDER_ADDRESSDisplay name for the sender.Environment variable:
TRAIL_EMAIL_SENDER_NAMEEmail Templates
Email templates support variable substitution:{{ VERIFICATION_URL }}- Full verification link{{ CODE }}- Verification code only
Template for user email verification emails.
Template for email change confirmation emails.
Template for password reset emails.
Database Configuration
Additional databases to attach. Main and logs databases are always attached.
Database name. Must be alphanumeric with
_ or -. Cannot be “main”, “logs”, or empty.Environment variable: TRAIL_DATABASES_<INDEX>_NAMERecord APIs Configuration
Configuration for table-based REST APIs.
API endpoint name.
Database table name.
JSON Schema Configuration
Custom JSON schemas for validation.
Schema identifier.
JSON Schema definition (as string).
Job Configuration
Scheduled system jobs using cron syntax.
Unique job identifier.
Cron expression (e.g.,
0 0 * * * for daily at midnight).Runtime Options
These options are set via CLI flags and cannot be changed via configuration files:Base directory for all TrailBase data. Requires server restart to change.
Public URL for external access. Requires server restart to change.
Server bind address. Requires server restart to change.
Separate admin interface address. Requires server restart to change.
WASM runtime thread pool size. Requires server restart to change.
A good rule of thumb: if a setting requires a server restart, it should be a CLI option. Otherwise, it should be in the config file.
Configuration Validation
TrailBase validates configuration on startup and when updating via the admin API. Validation checks:- Application name: Alphanumeric characters, spaces,
_,-,.only - URLs: Valid URL format for
site_url, OAuth URLs - Email addresses: Valid email format for sender addresses
- Database names: Alphanumeric with
_or-, not reserved names - API names: Unique across all configured APIs
- OAuth providers: Required fields present, valid provider IDs
- Cron schedules: Valid cron syntax
- JSON schemas: Valid JSON Schema format
Editing Configuration
Via Admin UI
The admin interface provides a configuration editor:- Navigate to Admin → Configuration
- Edit the configuration in the text editor
- Save changes
- Configuration is validated before saving
Via Text Editor
- Stop the TrailBase server
- Edit
<data-dir>/config.textproto - For secrets, edit
<data-dir>/secrets/secrets.textproto - Start the server (configuration is validated on startup)
Via Environment Variables
Set environment variables before starting the server:Secrets Management
How Secrets Work
- Writing: When you set a secret field in
config.textproto, TrailBase extracts it tosecrets.textprotoand replaces it with<REDACTED> - Reading: On startup, TrailBase merges secrets back into the configuration
- Environment override: Environment variables override both config and secrets
Secret Fields
The following fields are automatically treated as secrets:email.smtp_passwordauth.oauth_providers.*.client_secret- Any field marked with
[(secret) = true]in the protobuf definition
Rotating Secrets
Rotate SMTP password
Rotate SMTP password
Rotate OAuth secrets
Rotate OAuth secrets