Skip to content

🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!

5.3 KB
Raw Blame
# Warracker Environment Variables Configuration
# Copy this file to .env and customize the values for your deployment


### ** Database Configuration**

# Database connection settings
DB_HOST=warrackerdb
DB_NAME=warranty_db
DB_USER=warranty_user
DB_PASSWORD=warranty_password

# Optional: set both DB_ADMIN_USER and DB_ADMIN_PASSWORD if you want initial
# migrations to create a separate PostgreSQL admin role (no built-in defaults).
# DB_ADMIN_USER=warracker_admin
# DB_ADMIN_PASSWORD=your_secure_admin_password

# PostgreSQL-specific settings (for the database container)
POSTGRES_DB=warranty_db
POSTGRES_USER=warranty_user
POSTGRES_PASSWORD=warranty_password


###  Security Configuration**

# Application secret key for JWT tokens and Flask sessions
# IMPORTANT: Generate a strong, unique secret key for production
# (e.g. `openssl rand -hex 32`). If left empty, the app generates a
# random key on first start and persists it to a file.
SECRET_KEY=

# Optional: custom path for persisting an auto-generated SECRET_KEY (defaults to $UPLOAD_FOLDER/.secret_key)
# SECRET_KEY_FILE=/data/uploads/.secret_key

# Optional: set to true only if behind a reverse proxy on a public IP (local/private proxies are trusted automatically)
# TRUST_PROXY_HEADERS=false

# Optional: comma-separated origins allowed to send cross-origin requests with credentials
# CORS_ALLOWED_ORIGINS=

# JWT token expiration time (in hours)
JWT_EXPIRATION_HOURS=24


### Email/SMTP Configuration**

# SMTP server settings for sending notifications and password resets
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
[email protected]
SMTP_PASSWORD=your_email_password

# Optional SMTP settings
SMTP_USE_TLS=true
SMTP_USE_SSL=false
[email protected]


### **URL Configuration**

# Frontend URL (used for redirects and email links)
# IMPORTANT: Must match your public-facing URL for OIDC and email links to work
FRONTEND_URL=http://localhost:8005

# Application base URL (used for links in emails and redirects)
APP_BASE_URL=http://localhost:8005


### **File Upload Configuration**

# Maximum file upload size in megabytes
MAX_UPLOAD_MB=32

# Nginx maximum body size (should match or exceed MAX_UPLOAD_MB)
NGINX_MAX_BODY_SIZE_VALUE=32M

# Optional: total timeout (seconds) when fetching a product photo from a URL (default: 60)
# PHOTO_FETCH_TIMEOUT_SECONDS=60


### **Performance & Memory Configuration**

# Memory optimization mode
# Options: optimized (default), ultra-light, performance
# - optimized: 2 workers, ~60-80MB RAM usage (recommended for most deployments)
# - ultra-light: 1 worker, ~40-50MB RAM usage (for very limited resources)
# - performance: 4 workers, ~150-200MB RAM usage (for high-traffic deployments)
WARRACKER_MEMORY_MODE=optimized

# Optional: per-worker PostgreSQL connection pool sizing and wait timeout
# DB_POOL_MIN=1
# DB_POOL_MAX=4
# DB_POOL_WAIT_SECONDS=30


### **OIDC/SSO Configuration (Optional)**

# Enable/disable OIDC SSO functionality
OIDC_ENABLED=false

# OIDC-only mode: hide the username/password login form, OIDC login only
OIDC_ONLY_MODE=false

# Skip the login screen entirely and redirect straight to the OIDC provider
# (only takes effect when OIDC_ONLY_MODE is also true)
OIDC_SKIP_LOGIN_SCREEN=false

# OIDC Provider settings
# Provider name (affects button branding: google, github, microsoft, keycloak, etc.)
OIDC_PROVIDER_NAME=oidc

# OIDC client credentials (obtain from your OIDC provider)
OIDC_CLIENT_ID=
OIDC_CLIENT_SECRET=

# OIDC issuer URL (e.g., https://accounts.google.com)
OIDC_ISSUER_URL=

# OIDC scope (space-separated list of scopes)
OIDC_SCOPE=openid email profile

# OIDC admin group (optional, requires group scope)
OIDC_ADMIN_GROUP=

### **Development/Debugging Configuration (Optional)**

# Flask environment (development/production)
FLASK_ENV=production

# Flask debug mode (true/false)
FLASK_DEBUG=false

# Flask run port (for development)
FLASK_RUN_PORT=5000

# Python unbuffered output (helpful for Docker logs)
PYTHONUNBUFFERED=1


### **Example Configurations**

**Gmail SMTP:**
```bash
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
[email protected]
SMTP_PASSWORD=your_app_password
SMTP_USE_TLS=true
```

**Google OIDC:**
```bash
OIDC_ENABLED=true
OIDC_PROVIDER_NAME=google
OIDC_CLIENT_ID=your_google_client_id.apps.googleusercontent.com
OIDC_CLIENT_SECRET=your_google_client_secret
OIDC_ISSUER_URL=https://accounts.google.com
OIDC_SCOPE=openid email profile
```

**Production deployment:**
```bash
SECRET_KEY=super_long_random_string_generated_securely
DB_PASSWORD=strong_database_password_123
FRONTEND_URL=https://warracker.yourdomain.com
APP_BASE_URL=https://warracker.yourdomain.com
SMTP_HOST=smtp.yourdomain.com
[email protected]
MAX_UPLOAD_MB=64
NGINX_MAX_BODY_SIZE_VALUE=64M
WARRACKER_MEMORY_MODE=performance
```

## **How to Use**

1. **Copy this configuration** into a file named `.env` in your Docker folder
2. **Customize the values** according to your specific deployment needs
3. **Generate strong passwords** for production use, especially for `SECRET_KEY` and `DB_PASSWORD` (and `DB_ADMIN_PASSWORD` if using the optional admin role)
4. **Set your domain URLs** correctly for `FRONTEND_URL` and `APP_BASE_URL` if deploying publicly
5. **Configure SMTP** if you want email functionality for password resets and notifications
6. **Set up OIDC/SSO** if you want single sign-on capabilities