# =============================================================================
# Trigger.dev Configuration
# =============================================================================

# Global settings
TZ=UTC
GLOBAL_REGISTRY=

# =============================================================================
# Image Versions
# =============================================================================

# Trigger.dev version (webapp and supervisor)
TRIGGER_IMAGE_TAG=v4.2.0

# Infrastructure versions
POSTGRES_VERSION=17.2-alpine3.21
REDIS_VERSION=7.4.3-alpine3.21
CLICKHOUSE_VERSION=25.3
MINIO_VERSION=RELEASE.2025-04-22T22-12-26Z
MC_VERSION=RELEASE.2025-04-16T18-13-26Z
ELECTRIC_VERSION=1.0.0
REGISTRY_IMAGE_VERSION=3
DOCKER_SOCKET_PROXY_VERSION=0.3.0

# =============================================================================
# Port Configuration
# =============================================================================

# Webapp port
TRIGGER_PORT=8030

# MinIO ports
MINIO_API_PORT=9000
MINIO_CONSOLE_PORT=9001

# Registry port
REGISTRY_PORT=5000

# =============================================================================
# Required Secrets (MUST be set)
# =============================================================================

# Generate with: openssl rand -hex 16
SESSION_SECRET=
MAGIC_LINK_SECRET=
ENCRYPTION_KEY=

# Managed worker secret (must match between webapp and supervisor)
MANAGED_WORKER_SECRET=managed-secret

# PostgreSQL password
POSTGRES_PASSWORD=

# =============================================================================
# Domain Configuration
# =============================================================================

# Public URLs (change these for production)
APP_ORIGIN=http://localhost:8030
LOGIN_ORIGIN=http://localhost:8030
API_ORIGIN=http://localhost:8030
STREAM_ORIGIN=http://localhost:8030

# =============================================================================
# Database Configuration
# =============================================================================

# PostgreSQL
POSTGRES_USER=trigger
POSTGRES_DB=trigger
DATABASE_CONNECTION_LIMIT=10

# =============================================================================
# ClickHouse Configuration
# =============================================================================

CLICKHOUSE_DATABASE=default
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=password

# =============================================================================
# Object Storage Configuration (MinIO)
# =============================================================================

MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD=very-safe-password
PACKET_BUCKET_NAME=packets

# =============================================================================
# Registry Configuration
# =============================================================================

# Registry host (internal)
REGISTRY_HOST=trigger-registry:5000

# Registry credentials (generate htpasswd file)
REGISTRY_USER=registry-user
REGISTRY_PASSWORD=very-secure-indeed

# =============================================================================
# Authentication Configuration
# =============================================================================

# Restrict login to specific email addresses (regex pattern)
# Example: ^(user1@example\.com|user2@example\.com)$
WHITELISTED_EMAILS=

# GitHub OAuth (optional)
AUTH_GITHUB_CLIENT_ID=
AUTH_GITHUB_CLIENT_SECRET=

# =============================================================================
# Email Configuration (optional)
# =============================================================================

# Transport: resend, smtp, or aws-ses
EMAIL_TRANSPORT=

# Email addresses
FROM_EMAIL=
REPLY_TO_EMAIL=

# Resend configuration
RESEND_API_KEY=

# SMTP configuration
SMTP_HOST=
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=
SMTP_PASSWORD=

# AWS SES (uses AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

# =============================================================================
# Telemetry
# =============================================================================

# Set to any non-empty value to disable telemetry
TRIGGER_TELEMETRY_DISABLED=

# =============================================================================
# Bootstrap Configuration
# =============================================================================

# Enable automatic worker group creation
TRIGGER_BOOTSTRAP_ENABLED=true
TRIGGER_BOOTSTRAP_WORKER_GROUP_NAME=bootstrap

# Worker token (auto-generated on first run, or set manually for remote workers)
# Format: tr_wgt_... (obtained from webapp logs on first run)
TRIGGER_WORKER_TOKEN=file:///home/node/shared/worker_token

# =============================================================================
# Supervisor Configuration
# =============================================================================

# Worker instance name (unique per supervisor)
TRIGGER_WORKER_INSTANCE_NAME=supervisor-1
TRIGGER_WORKER_HEARTBEAT_INTERVAL_SECONDS=30

# Docker settings
DOCKER_ENFORCE_MACHINE_PRESETS=true
DOCKER_AUTOREMOVE_EXITED_CONTAINERS=true

# =============================================================================
# Resource Limits
# =============================================================================

# Webapp
WEBAPP_CPU_LIMIT=3.0
WEBAPP_MEMORY_LIMIT=6G
WEBAPP_CPU_RESERVATION=1.0
WEBAPP_MEMORY_RESERVATION=2G

# PostgreSQL
POSTGRES_CPU_LIMIT=2.0
POSTGRES_MEMORY_LIMIT=4G
POSTGRES_CPU_RESERVATION=0.5
POSTGRES_MEMORY_RESERVATION=1G

# Redis
REDIS_CPU_LIMIT=1.0
REDIS_MEMORY_LIMIT=2G
REDIS_CPU_RESERVATION=0.25
REDIS_MEMORY_RESERVATION=512M

# ClickHouse
CLICKHOUSE_CPU_LIMIT=2.0
CLICKHOUSE_MEMORY_LIMIT=4G
CLICKHOUSE_CPU_RESERVATION=0.5
CLICKHOUSE_MEMORY_RESERVATION=1G

# MinIO
MINIO_CPU_LIMIT=1.0
MINIO_MEMORY_LIMIT=2G
MINIO_CPU_RESERVATION=0.25
MINIO_MEMORY_RESERVATION=512M

# Electric
ELECTRIC_CPU_LIMIT=1.0
ELECTRIC_MEMORY_LIMIT=1G
ELECTRIC_CPU_RESERVATION=0.25
ELECTRIC_MEMORY_RESERVATION=256M

# Registry
REGISTRY_CPU_LIMIT=0.5
REGISTRY_MEMORY_LIMIT=512M
REGISTRY_CPU_RESERVATION=0.1
REGISTRY_MEMORY_RESERVATION=128M

# Supervisor
SUPERVISOR_CPU_LIMIT=2.0
SUPERVISOR_MEMORY_LIMIT=4G
SUPERVISOR_CPU_RESERVATION=0.5
SUPERVISOR_MEMORY_RESERVATION=1G

# Docker Socket Proxy
DOCKER_PROXY_CPU_LIMIT=0.5
DOCKER_PROXY_MEMORY_LIMIT=256M
DOCKER_PROXY_CPU_RESERVATION=0.1
DOCKER_PROXY_MEMORY_RESERVATION=64M
