# Gitea Mirror Configuration
# Copy this to .env and update with your values

# ===========================================
# CORE CONFIGURATION
# ===========================================

# Application Configuration
NODE_ENV=production
HOST=0.0.0.0
PORT=4321

# Database Configuration
# For self-hosted, SQLite is used by default
DATABASE_URL=sqlite://data/gitea-mirror.db

# Security
# Generate with: openssl rand -base64 32
BETTER_AUTH_SECRET=change-this-to-a-secure-random-string-in-production
BETTER_AUTH_URL=http://localhost:4321
# PUBLIC_BETTER_AUTH_URL=https://your-domain.com  # Optional: Set this if accessing from different origins (e.g., IP and domain)
# ENCRYPTION_SECRET=optional-encryption-key-for-token-encryption # Generate with: openssl rand -base64 48

# ===========================================
# DOCKER CONFIGURATION (Optional)
# ===========================================

# Docker Registry Configuration
DOCKER_REGISTRY=ghcr.io
DOCKER_IMAGE=raylabshq/gitea-mirror:
DOCKER_TAG=latest

# ===========================================
# GITHUB CONFIGURATION
# All settings can also be configured via web UI
# ===========================================

# Basic GitHub Settings
# GITHUB_USERNAME=your-github-username
# GITHUB_TOKEN=your-github-personal-access-token
# GITHUB_TYPE=personal  # Options: personal, organization

# Repository Selection
# PRIVATE_REPOSITORIES=false
# PUBLIC_REPOSITORIES=true
# INCLUDE_ARCHIVED=false
# SKIP_FORKS=false
# MIRROR_STARRED=false
# STARRED_REPOS_ORG=starred  # Organization name for starred repos

# Organization Settings
# MIRROR_ORGANIZATIONS=false
# PRESERVE_ORG_STRUCTURE=false
# ONLY_MIRROR_ORGS=false

# Mirror Strategy
# MIRROR_STRATEGY=preserve  # Options: preserve, single-org, flat-user, mixed

# Advanced GitHub Settings
# SKIP_STARRED_ISSUES=false  # Enable lightweight mode for starred repos

# ===========================================
# GITEA CONFIGURATION
# All settings can also be configured via web UI
# ===========================================

# Basic Gitea Settings
# GITEA_URL=http://gitea:3000
# GITEA_TOKEN=your-local-gitea-token
# GITEA_USERNAME=your-local-gitea-username
# GITEA_ORGANIZATION=github-mirrors  # Default organization for single-org strategy

# Repository Settings
# GITEA_ORG_VISIBILITY=public  # Options: public, private, limited, default
# GITEA_MIRROR_INTERVAL=8h  # Mirror sync interval (e.g., 30m, 1h, 8h, 24h) - automatically enables scheduler
# GITEA_LFS=false  # Enable LFS support
# GITEA_CREATE_ORG=true  # Auto-create organizations
# GITEA_PRESERVE_VISIBILITY=false  # Preserve GitHub repo visibility in Gitea

# Template Settings (for using repository templates)
# GITEA_TEMPLATE_OWNER=template-owner
# GITEA_TEMPLATE_REPO=template-repo

# Topic Settings
# GITEA_ADD_TOPICS=true  # Add topics to repositories
# GITEA_TOPIC_PREFIX=gh-  # Prefix for topics

# Fork Handling
# GITEA_FORK_STRATEGY=reference  # Options: skip, reference, full-copy

# ===========================================
# MIRROR OPTIONS
# Control what gets mirrored from GitHub
# ===========================================

# Release and Metadata
# MIRROR_RELEASES=false  # Mirror GitHub releases
# RELEASE_LIMIT=10  # Maximum number of releases to mirror per repository
# MIRROR_WIKI=false  # Mirror wiki content

# Issue Tracking (requires MIRROR_METADATA=true)
# MIRROR_METADATA=false  # Master toggle for metadata mirroring
# MIRROR_ISSUES=false  # Mirror issues
# MIRROR_PULL_REQUESTS=false  # Mirror pull requests
# MIRROR_LABELS=false  # Mirror labels
# MIRROR_MILESTONES=false  # Mirror milestones

# ===========================================
# AUTOMATION CONFIGURATION
# Schedule automatic mirroring
# ===========================================

# Basic Schedule Settings
# SCHEDULE_ENABLED=false  # When true, auto-imports and mirrors all repos on startup (v3.5.3+)
# SCHEDULE_INTERVAL=3600  # Interval in seconds or cron expression (e.g., "0 2 * * *")
# GITEA_MIRROR_INTERVAL=8h  # Mirror sync interval (5m, 30m, 1h, 8h, 24h, 1d, 7d) - also triggers auto-start
# AUTO_IMPORT_REPOS=true  # Automatically discover and import new GitHub repositories during syncs
# DELAY=3600  # Legacy: same as SCHEDULE_INTERVAL, kept for backward compatibility

# Execution Settings
# SCHEDULE_CONCURRENT=false  # Allow concurrent mirror operations
# SCHEDULE_BATCH_SIZE=10  # Number of repos to process in parallel
# SCHEDULE_PAUSE_BETWEEN_BATCHES=5000  # Pause between batches (ms)

# Retry Configuration
# SCHEDULE_RETRY_ATTEMPTS=3
# SCHEDULE_RETRY_DELAY=60000  # Delay between retries (ms)
# SCHEDULE_TIMEOUT=3600000  # Max time for a mirror operation (ms)
# SCHEDULE_AUTO_RETRY=true

# Update Detection
# SCHEDULE_ONLY_MIRROR_UPDATED=false  # Only mirror repos with updates
# SCHEDULE_UPDATE_INTERVAL=86400000  # Check for updates interval (ms)
# SCHEDULE_SKIP_RECENTLY_MIRRORED=true
# SCHEDULE_RECENT_THRESHOLD=3600000  # Skip if mirrored within this time (ms)

# Maintenance
# SCHEDULE_CLEANUP_BEFORE_MIRROR=false  # Run cleanup before mirroring

# Notifications
# SCHEDULE_NOTIFY_ON_FAILURE=true
# SCHEDULE_NOTIFY_ON_SUCCESS=false
# SCHEDULE_LOG_LEVEL=info  # Options: error, warn, info, debug
# SCHEDULE_TIMEZONE=UTC

# ===========================================
# DATABASE CLEANUP CONFIGURATION
# Automatic cleanup of old events and data
# ===========================================

# Basic Cleanup Settings
# CLEANUP_ENABLED=false
# CLEANUP_RETENTION_DAYS=7  # Days to keep events

# Repository Cleanup (v3.4.0+)
# CLEANUP_DELETE_FROM_GITEA=false  # Delete repos from Gitea
# CLEANUP_DELETE_IF_NOT_IN_GITHUB=false  # Auto-remove repos that no longer exist in GitHub
# CLEANUP_ORPHANED_REPO_ACTION=archive  # Options: skip, archive, delete
# CLEANUP_DRY_RUN=true  # Test mode without actual deletion (set to false for production)

# Protected Repositories (comma-separated)
# CLEANUP_PROTECTED_REPOS=important-repo,critical-project

# Cleanup Execution
# CLEANUP_BATCH_SIZE=10
# CLEANUP_PAUSE_BETWEEN_DELETES=2000  # Pause between deletions (ms)

# ===========================================
# AUTHENTICATION CONFIGURATION
# ===========================================

# Header Authentication (for Reverse Proxy SSO)
# Enable automatic authentication via reverse proxy headers
# HEADER_AUTH_ENABLED=false
# HEADER_AUTH_USER_HEADER=X-Authentik-Username
# HEADER_AUTH_EMAIL_HEADER=X-Authentik-Email
# HEADER_AUTH_NAME_HEADER=X-Authentik-Name
# HEADER_AUTH_AUTO_PROVISION=false
# HEADER_AUTH_ALLOWED_DOMAINS=example.com,company.org

# ===========================================
# OPTIONAL FEATURES
# ===========================================

# TLS/SSL Configuration
# GITEA_SKIP_TLS_VERIFY=false  # WARNING: Only use for testing