Configuration Sources
TrailBase reads configuration from three sources in order of precedence:- Environment variables (highest priority) -
TRAIL_*prefix - Configuration files -
config.textprotoandsecrets.textproto - Command-line flags - Passed to the
trailcommand - Defaults (lowest priority)
Environment variables always override configuration files and defaults. This is useful for Docker deployments and CI/CD pipelines.
Command-Line Options
Global Flags
These flags apply to all subcommands:--data-dir <PATH>
Directory for runtime files including databases, configuration, and WASM components.
- Default:
./traildepot - Environment variable:
DATA_DIR - Example:
The data directory will be created automatically if it doesn’t exist. Ensure the user running TrailBase has write permissions.
--public-url <URL>
Public URL used to access TrailBase. Required for:
- Sending authentication emails with correct links
- OAuth2 redirect URLs
- Generating absolute URLs in APIs
- Default: None (optional)
-
Environment variable:
PUBLIC_URL -
Example:
--version
Print TrailBase version information and exit.
Run Command Options
Options for thetrail run subcommand:
--address <HOST:PORT>
HTTP server bind address.
- Default:
localhost:4000 - Environment variable:
ADDRESS - Examples:
--admin-address <HOST:PORT>
Optional separate address for admin UI and APIs.
- Default: None (admin served on main address)
- Environment variable:
ADMIN_ADDRESS - Example:
- Public APIs: Served on
--address - Admin UI & APIs: Served on
--admin-address
--public-dir <PATH>
Optional path to static assets served at the HTTP root.
- Default: None
- Environment variable:
PUBLIC_DIR - Example:
/index.html→/var/www/app/index.html/assets/style.css→/var/www/app/assets/style.css/api/records/v1/users→ TrailBase API (not a file)
--spa
Enable Single Page Application (SPA) fallback mode.
- Default:
false - Environment variable:
SPA - Example:
- Routes (paths without extensions) →
index.html - File requests (e.g.,
.css,.js) → serve file or 404 - API routes → TrailBase APIs
Requires
--public-dir to be set. Perfect for React, Vue, Angular, or Svelte apps.--runtime-root-fs <PATH>
Sandboxed filesystem root for WASM runtime.
- Default: None (WASM has no filesystem access)
- Environment variable:
RUNTIME_ROOT_FS - Example:
--geoip-db-path <PATH>
Path to MaxMind GeoIP database for IP geolocation.
- Default: None (geolocation disabled)
- Environment variable:
GEOIP_DB_PATH - Example:
--dev
Enable development mode with permissive CORS and cookies.
- Default:
false - Example:
- Allows cross-origin requests from any origin
- Enables credentials in cross-origin requests
- Useful for frontend dev servers
--demo
Demo mode - redacts PII from logs.
- Default:
false - Example:
--stderr-logging
Log to stderr instead of the database.
- Default:
false - Example:
- Docker/Kubernetes (logs to container stdout)
- Systemd (logs to journald)
- Log aggregation systems
--cors-allowed-origins <ORIGINS>
Comma-separated list of allowed CORS origins.
- Default:
*(all origins) - Example:
For production, always restrict CORS to your specific domains.
--runtime-threads <N>
Number of JavaScript isolates/workers for WASM runtime.
- Default: Number of CPU cores
- Environment variable:
RUNTIME_THREADS - Example:
Configuration Files
TrailBase uses Protocol Buffer text format for configuration.config.textproto
Main configuration file in<data-dir>/config/config.textproto:
secrets.textproto
Sensitive values in<data-dir>/secrets/secrets.textproto:
Environment Variables
All configuration options can be set via environment variables with theTRAIL_ prefix.
Naming Convention
Environment variables follow this pattern:TRAIL_SERVER_APPLICATION_NAMETRAIL_EMAIL_SMTP_HOSTTRAIL_EMAIL_SMTP_PORTTRAIL_AUTH_AUTH_TOKEN_TTL_SECTRAIL_AUTH_OAUTH_PROVIDERS_GOOGLE_CLIENT_ID
Common Environment Variables
Server Configuration
Authentication
Email Configuration
OAuth Providers
For map fields like OAuth providers, use the provider name in uppercase:Docker Environment Variables
Example docker-compose with environment variables:docker-compose.yml
Other Subcommands
TrailBase includes additional subcommands for management:Schema Export
Export JSON Schema for an API:insert- Schema for creating recordsselect- Schema for reading recordsupdate- Schema for updating records
OpenAPI Export
Export OpenAPI specification:Migrations
Create a new migration file:traildepot/migrations/main/U<timestamp>__create_users_table.sql
Admin Management
Manage admin users:User Management
Manage users from the command line:Email Testing
Send test emails:WASM Components
Manage WASM components:Default Values
Key default values:- Data directory:
./traildepot - Server address:
localhost:4000 - Auth token TTL: 60 minutes (2 minutes in debug builds)
- Refresh token TTL: 30 days
- Log retention: 7 days
- CORS origins:
*(all origins) - Runtime threads: Number of CPU cores
Configuration Best Practices
Use environment variables for secrets
Use environment variables for secrets
Never commit secrets to version control. Use environment variables or encrypted secrets management.
Validate configuration changes
Validate configuration changes
After editing
config.textproto, restart TrailBase and check logs for validation errors:Back up configuration files
Back up configuration files
Include
config.textproto and secrets.textproto in backups:Use --public-url in production
Use --public-url in production
Always set the public URL for OAuth and email links to work correctly:
Troubleshooting
Configuration Not Loading
Check file paths and permissions:Environment Variables Not Working
Verify the variable name follows the correct pattern:OAuth Redirects Failing
Ensure--public-url matches your OAuth provider’s redirect URL:
Next Steps
Production Setup
Production checklist, security, and monitoring
Self-Hosting
Learn about deployment strategies and installation