From cbf6e11de3aeae901ffca9f31c235fbc98f4721b Mon Sep 17 00:00:00 2001 From: Arunavo Ray Date: Fri, 29 Aug 2025 18:11:26 +0530 Subject: [PATCH] Env var updates --- .env.example | 8 +++++--- README.md | 43 +++++++++++++++++++++++++++++------------- docker-compose.alt.yml | 40 +++++++++++++++++++++++++++++++++------ docker-compose.yml | 8 ++++++++ 4 files changed, 77 insertions(+), 22 deletions(-) diff --git a/.env.example b/.env.example index c96c953..5f665b0 100644 --- a/.env.example +++ b/.env.example @@ -111,6 +111,8 @@ DOCKER_TAG=latest # Basic Schedule Settings # SCHEDULE_ENABLED=false # 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) +# AUTO_IMPORT_REPOS=true # Automatically discover and import new GitHub repositories # DELAY=3600 # Legacy: same as SCHEDULE_INTERVAL, kept for backward compatibility # Execution Settings @@ -148,11 +150,11 @@ DOCKER_TAG=latest # CLEANUP_ENABLED=false # CLEANUP_RETENTION_DAYS=7 # Days to keep events -# Repository Cleanup +# Repository Cleanup (v3.4.0+) # CLEANUP_DELETE_FROM_GITEA=false # Delete repos from Gitea -# CLEANUP_DELETE_IF_NOT_IN_GITHUB=true # Delete if not in GitHub - automatically enables cleanup +# 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 +# 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 diff --git a/README.md b/README.md index ea7db22..f54b9f1 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,10 @@ First user signup becomes admin. Configure GitHub and Gitea through the web inte - ๐Ÿšซ **Repository ignore** - Mark specific repos to skip - ๐Ÿ” Secure authentication with Better Auth (email/password, SSO, OIDC) - ๐Ÿ“Š Real-time dashboard with activity logs -- โฑ๏ธ Scheduled automatic mirroring with flexible intervals +- โฑ๏ธ Scheduled automatic mirroring with configurable intervals +- ๐Ÿ”„ **Auto-discovery** - Automatically import new GitHub repositories (v3.4.0+) +- ๐Ÿงน **Repository cleanup** - Auto-remove repos deleted from GitHub (v3.4.0+) +- ๐ŸŽฏ **Proper mirror intervals** - Respects configured sync intervals (v3.4.0+) - ๐Ÿ—‘๏ธ Automatic database cleanup with configurable retention - ๐Ÿณ Dockerized with multi-arch support (AMD64/ARM64) @@ -204,25 +207,39 @@ Enable in Settings โ†’ Mirror Options โ†’ Mirror metadata - **Automatic Cleanup** - Configure retention period for activity logs - **Scheduled Sync** - Set custom intervals for automatic mirroring -### Automatic Mirroring +### Automatic Mirroring & Synchronization -Gitea Mirror can automatically sync your repositories at regular intervals. There are two ways to configure this: +Gitea Mirror provides powerful automatic synchronization features: -#### Via Web Interface (Recommended) -Navigate to the Configuration page and enable "Automatic Mirroring" with your preferred interval (e.g., every 6 hours, daily, etc.). +#### Features (v3.4.0+) +- **Auto-discovery**: Automatically discovers and imports new GitHub repositories +- **Repository cleanup**: Removes repositories that no longer exist in GitHub +- **Proper intervals**: Mirrors respect your configured sync intervals (not Gitea's default 24h) +- **Smart scheduling**: Only syncs repositories that need updating -#### Via Environment Variables -Set `GITEA_MIRROR_INTERVAL` to automatically enable scheduled mirroring: +#### Configuration via Web Interface (Recommended) +Navigate to the Configuration page and enable "Automatic Mirroring" with your preferred interval. + +#### Configuration via Environment Variables ```bash -# Examples of supported formats: -GITEA_MIRROR_INTERVAL=8h # Every 8 hours -GITEA_MIRROR_INTERVAL=30m # Every 30 minutes -GITEA_MIRROR_INTERVAL=1d # Daily -GITEA_MIRROR_INTERVAL=86400 # Every 86400 seconds (24 hours) +# Enable automatic scheduling (required for auto features) +SCHEDULE_ENABLED=true + +# Mirror interval (how often to sync) +GITEA_MIRROR_INTERVAL=8h # Every 8 hours (default) +# Other examples: 5m, 30m, 1h, 24h, 1d, 7d + +# Auto-import new repositories (default: true) +AUTO_IMPORT_REPOS=true + +# Auto-cleanup orphaned repositories +CLEANUP_DELETE_IF_NOT_IN_GITHUB=true +CLEANUP_ORPHANED_REPO_ACTION=archive # or 'delete' +CLEANUP_DRY_RUN=false # Set to true to test without changes ``` -When this variable is set, the scheduler automatically enables and runs at the specified interval. The timer starts from the last successful sync, not from container startup. +**Important**: The scheduler checks every minute for tasks to run. The `GITEA_MIRROR_INTERVAL` determines how often each repository is actually synced. For example, with `8h`, each repo syncs every 8 hours from its last successful sync. ## Troubleshooting diff --git a/docker-compose.alt.yml b/docker-compose.alt.yml index 425c898..c859e69 100644 --- a/docker-compose.alt.yml +++ b/docker-compose.alt.yml @@ -1,5 +1,7 @@ -# Gitea Mirror alternate deployment configuration -# Standard deployment with host path and minimal environments +# Minimal Gitea Mirror deployment +# Only includes what CANNOT be configured via the Web UI +# Everything else can be set up through the web interface after deployment + services: gitea-mirror: image: ghcr.io/raylabshq/gitea-mirror:latest @@ -11,17 +13,43 @@ services: volumes: - ./data:/app/data environment: - # For a complete list of all supported environment variables, see: - # docs/ENVIRONMENT_VARIABLES.md or .env.example + # === ABSOLUTELY REQUIRED === + # This MUST be set and CANNOT be changed via UI + - BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET} # Min 32 chars, required for sessions + + # === CORE SETTINGS === + # These are technically required but have working defaults - NODE_ENV=production - DATABASE_URL=file:data/gitea-mirror.db - HOST=0.0.0.0 - PORT=4321 - - BETTER_AUTH_URL=http://localhost:4321 - - BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-your-secret-key-change-this-in-production} + - BETTER_AUTH_URL=${BETTER_AUTH_URL:-http://localhost:4321} + healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=3", "--spider", "http://localhost:4321/api/health"] interval: 30s timeout: 10s retries: 5 start_period: 15s + +# === QUICK START === +# +# 1. Create a .env file with only ONE required variable: +# BETTER_AUTH_SECRET=your-32-character-minimum-secret-key-here +# +# 2. Run: +# docker-compose -f docker-compose.alt.yml up -d +# +# 3. Access at http://localhost:4321 +# +# 4. Sign up for an account (first user becomes admin) +# +# 5. Configure everything else through the web UI: +# - GitHub credentials +# - Gitea credentials +# - Mirror settings +# - Scheduling options +# - Auto-import settings +# - Cleanup preferences +# +# That's it! Everything else can be configured via the web interface. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b16f242..fad79c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,6 +53,14 @@ services: - GITEA_ORGANIZATION=${GITEA_ORGANIZATION:-github-mirrors} - GITEA_ORG_VISIBILITY=${GITEA_ORG_VISIBILITY:-public} - DELAY=${DELAY:-3600} + # Scheduling and Sync Configuration (Issue #72 fixes) + - SCHEDULE_ENABLED=${SCHEDULE_ENABLED:-false} + - GITEA_MIRROR_INTERVAL=${GITEA_MIRROR_INTERVAL:-8h} + - AUTO_IMPORT_REPOS=${AUTO_IMPORT_REPOS:-true} + # Repository Cleanup Configuration + - CLEANUP_DELETE_IF_NOT_IN_GITHUB=${CLEANUP_DELETE_IF_NOT_IN_GITHUB:-false} + - CLEANUP_ORPHANED_REPO_ACTION=${CLEANUP_ORPHANED_REPO_ACTION:-archive} + - CLEANUP_DRY_RUN=${CLEANUP_DRY_RUN:-true} # Optional: Skip TLS verification (insecure, use only for testing) # - GITEA_SKIP_TLS_VERIFY=${GITEA_SKIP_TLS_VERIFY:-false} # Header Authentication (for Reverse Proxy SSO)