Overview
suSHi uses environment variables for configuration, loaded via theutils/load_config.go module. All settings can be configured through environment variables, with some having default values.
Configuration Loading
The application loads configuration in the following order:- Environment variables (highest priority)
- OAuth configuration from
config/oauth.yaml - Default values (lowest priority)
os.Getenv() function.
Core Configuration
Server Settings
Port number for the HTTP server.Example:
8080Used in: docker-compose.yaml:30, load_config.go:20Logging level for the application. Valid values:
Debug, Info, Warn, Error.Example: DebugUsed in: docker-compose.yaml:31, load_config.go:22Directory path for log files. Trailing slashes are automatically removed.Example:
./logs or /var/log/sushiUsed in: load_config.go:23, load_config.go:42-46Secret key for signing JWT tokens. Must be kept secure.Minimum length: 32 characters recommendedExample:
your_random_jwt_secret_min_32_charsUsed in: docker-compose.yaml:32, load_config.go:21Database Configuration
All database connection parameters are loaded from environment variables and used to construct the connection string.PostgreSQL database host. Use
postgres when running with Docker Compose (service name), or localhost for local development.Example: postgres (Docker) or localhostUsed in: docker-compose.yaml:33, load_config.go:32PostgreSQL database port.Default PostgreSQL port:
5432Used in: docker-compose.yaml:34, load_config.go:33PostgreSQL database username.Example:
postgresUsed in: docker-compose.yaml:35, load_config.go:34PostgreSQL database password.Example:
secure_password_hereUsed in: docker-compose.yaml:36, load_config.go:35PostgreSQL database name.Example:
sushiUsed in: docker-compose.yaml:37, load_config.go:36Enable automatic database migrations on startup. Set to
true to run migrations automatically.Example: trueUsed in: docker-compose.yaml:38, load_config.go:38, migrations.go:13-18When enabled, the application will automatically run all pending migrations from the db/migrations/ directory using Goose.OAuth Authentication
suSHi supports OAuth authentication with Google and GitHub. Configuration is loaded from both environment variables and theconfig/oauth.yaml file.
Google OAuth
Google OAuth 2.0 client ID from Google Cloud Console.Used in:
docker-compose.yaml:41, load_config.go:66, oauth.yaml:3How to obtain: Create OAuth 2.0 credentials in Google Cloud ConsoleGoogle OAuth 2.0 client secret.Used in:
docker-compose.yaml:42, load_config.go:67, oauth.yaml:4OAuth callback URL for Google authentication.Example:
http://localhost:8080/api/v1/auth/callbackUsed in: docker-compose.yaml:43, load_config.go:68, oauth.yaml:8OAuth Scopes (from oauth.yaml:5-7):https://www.googleapis.com/auth/userinfo.emailhttps://www.googleapis.com/auth/userinfo.profile
GitHub OAuth
GitHub OAuth App client ID.Used in:
docker-compose.yaml:45, load_config.go:69, oauth.yaml:12How to obtain: Create an OAuth App in GitHub Developer SettingsGitHub OAuth App client secret.Used in:
docker-compose.yaml:46, load_config.go:70, oauth.yaml:13OAuth callback URL for GitHub authentication.Example:
http://localhost:8080/api/v1/auth/callbackUsed in: docker-compose.yaml:47, load_config.go:71, oauth.yaml:17OAuth Scopes (from oauth.yaml:14-16):read:userread:email
SSH Configuration
These environment variables configure SSH connections for remote machine management.SSH server hostname or IP address.Used in:
load_config.go:26SSH server port.Used in:
load_config.go:27SSH username for authentication.Used in:
load_config.go:28Path to SSH private key file or the private key content.Used in:
load_config.go:29Configuration File Structure
The configuration is mapped to the following Go struct (frommodels/config.go):
Environment File Examples
Development (.env.development)
Production (.env.production)
Using Environment Files with Docker
To use an environment file with Docker Compose:Validation and Troubleshooting
Check Configuration Loading
Enable debug logging to see configuration values at startup:Common Issues
Database connection failed:- Verify
DB_HOST,DB_PORT,DB_USER,DB_PASSWORD, andDB_NAMEare correct - Ensure the database server is running and accessible
- Check firewall rules if using a remote database
- Verify client ID and secret are correct
- Ensure redirect URLs match exactly in both the OAuth provider settings and your configuration
- Check that the OAuth provider’s authorized domains include your application domain
- Ensure
MIGRATE_DB=true(notMIGRATE_DB=TrueorMIGRATE_DB=1) - Check that the database user has permission to create tables
- Review logs for migration errors
Next Steps
- Learn about Database Setup and schema
- Set up Docker Deployment
- Configure OAuth providers in Google Cloud Console and GitHub