diff --git a/README.md b/README.md index 27608b7..5a6fa0a 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ docker compose -f docker-compose.alt.yml up -d First user signup becomes admin. Configure GitHub and Gitea/Forgejo through the web interface! +๐Ÿ“– **[Full documentation](https://gitea-mirror.raylabs.io/docs/)** - quickstart, deployment, configuration, notifications, SSO and more. Offline copies live in [`docs/`](docs/). +

Dashboard Dashboard Mobile @@ -33,15 +35,16 @@ First user signup becomes admin. Configure GitHub and Gitea/Forgejo through the - ๐Ÿข Mirror entire organizations with flexible strategies - ๐ŸŽฏ Custom destination control for repos and organizations - ๐Ÿ“ฆ **Git LFS support** - Mirror large files with Git LFS -- ๐Ÿ“ **Metadata mirroring** - Issues, pull requests (as issues), labels, milestones, wiki +- ๐Ÿ“ **Metadata mirroring** - Issues, pull requests (as issues), labels, milestones, releases, wiki - ๐Ÿšซ **Repository ignore** - Mark specific repos to skip -- ๐Ÿ” Secure authentication with Better Auth (email/password, SSO, OIDC) +- ๐Ÿ” Secure authentication with Better Auth (email/password, SSO, OIDC, header auth) +- ๐Ÿ”” **[Notifications](docs/NOTIFICATIONS.md)** - ntfy, Apprise, Gotify, or any webhook with signed payloads - ๐Ÿ“Š Real-time dashboard with activity logs - โฑ๏ธ 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+) -- ๐Ÿ›ก๏ธ **[Force-push protection](docs/FORCE_PUSH_PROTECTION.md)** - Smart detection with backup-on-demand or block-and-approve modes (Beta) +- ๐Ÿ”„ **Auto-discovery** - Automatically import new GitHub repositories +- ๐Ÿงน **Repository cleanup** - Auto-remove repos deleted from GitHub +- ๐ŸŽฏ **Proper mirror intervals** - Respects configured sync intervals +- ๐Ÿ›ก๏ธ **[Force-push protection](docs/FORCE_PUSH_PROTECTION.md)** - Smart detection with backup-on-demand or block-and-approve modes - ๐Ÿ—‘๏ธ Automatic database cleanup with configurable retention - ๐Ÿณ Dockerized with multi-arch support (AMD64/ARM64) @@ -49,7 +52,7 @@ First user signup becomes admin. Configure GitHub and Gitea/Forgejo through the

Repositories - Rrepositories Mobile + Repositories Mobile
diff --git a/docs/NOTIFICATIONS.md b/docs/NOTIFICATIONS.md index d632c0a..d7b21b6 100644 --- a/docs/NOTIFICATIONS.md +++ b/docs/NOTIFICATIONS.md @@ -54,13 +54,60 @@ Gitea Mirror supports push notifications for mirror events. You can be alerted w - Optionally set a **Tag** to only notify specific Apprise services - Leave empty to notify all configured services +### 3. Gotify (Direct) + +[Gotify](https://gotify.net/) is a simple self-hosted push notification server. + +**Setup:** +1. In Gotify, create an application and copy its token +2. In Gitea Mirror, go to **Configuration > Notifications** +3. Enable notifications and select **Gotify** +4. Set the **Server URL** to your Gotify instance (e.g., `https://gotify.example.com`) +5. Paste the **Application token** +6. Pick a **Default priority** (0 to 10; error notifications are always sent at priority 8) + +The token is encrypted at rest like all other provider credentials. + +### 4. Webhook (Generic) + +Sends a plain JSON POST to any URL you control. Works with n8n, Home Assistant, or any service that accepts a generic webhook. + +**Setup:** +1. In Gitea Mirror, go to **Configuration > Notifications** +2. Enable notifications and select **Webhook** +3. Set the **Webhook URL** to your endpoint +4. Optionally set a **Signing secret** + +**Payload:** +```json +{ + "title": "Mirror Failed: my-repo", + "message": "Repository my-repo failed to mirror", + "type": "sync_error", + "timestamp": "2026-08-03T02:33:29.707Z" +} +``` + +**Signature verification:** +When a signing secret is set, every request includes an `X-Webhook-Signature` header containing `sha256=`, an HMAC-SHA256 digest of the raw request body. Verify it on the receiving end: + +```js +const crypto = require("node:crypto"); +const expected = "sha256=" + + crypto.createHmac("sha256", secret).update(rawBody).digest("hex"); +const valid = crypto.timingSafeEqual( + Buffer.from(signatureHeader), Buffer.from(expected)); +``` + +The secret is encrypted at rest. + ## Event Types | Event | Default | Description | |-------|---------|-------------| | Sync errors | On | A mirror job failed | | Sync success | Off | A mirror job completed successfully | -| New repo discovered | Off | A new GitHub repo was auto-imported during scheduled sync | +| New repo discovered | Off | Not yet implemented; the toggle is disabled in the UI | ## Testing diff --git a/helm/gitea-mirror/Chart.yaml b/helm/gitea-mirror/Chart.yaml index 042a837..ee513d4 100644 --- a/helm/gitea-mirror/Chart.yaml +++ b/helm/gitea-mirror/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: gitea-mirror description: Kubernetes helm chart for gitea-mirror type: application -version: 0.0.1 -appVersion: 3.7.2 +version: 0.0.2 +appVersion: "3.24.0" icon: https://github.com/RayLabsHQ/gitea-mirror/blob/main/.github/assets/logo.png keywords: - git diff --git a/src/components/NotFound.tsx b/src/components/NotFound.tsx index 4e63ea2..4deca0e 100644 --- a/src/components/NotFound.tsx +++ b/src/components/NotFound.tsx @@ -60,7 +60,7 @@ export function NotFound() { Config diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx index c4f63d7..5996190 100644 --- a/src/components/layout/Sidebar.tsx +++ b/src/components/layout/Sidebar.tsx @@ -165,7 +165,7 @@ export function Sidebar({ className, onNavigate, isOpen, isCollapsed = false, on Check out the documentation for help with setup and configuration.

- + {title} diff --git a/src/pages/docs/advanced.astro b/src/pages/docs/advanced.astro deleted file mode 100644 index cbcdd2d..0000000 --- a/src/pages/docs/advanced.astro +++ /dev/null @@ -1,525 +0,0 @@ ---- -import MainLayout from '../../layouts/main.astro'; -import { withBase } from '@/lib/base-path'; ---- - - -
- - -
- -
-
- - - - - Advanced -
-

Advanced Topics

-

- Advanced configuration options, deployment strategies, troubleshooting, and performance optimization for Gitea Mirror. -

-
- - -
-

Environment Variables

- -

- Gitea Mirror can be configured using environment variables. These are particularly useful for containerized deployments. -

- -
- - - - - - - - - - {[ - { var: 'NODE_ENV', desc: 'Application environment', default: 'production' }, - { var: 'PORT', desc: 'Server port', default: '4321' }, - { var: 'HOST', desc: 'Server host', default: '0.0.0.0' }, - { var: 'BASE_URL', desc: 'Application base path ("/" or e.g. "/mirror")', default: '/' }, - { var: 'BETTER_AUTH_SECRET', desc: 'Authentication secret key', default: 'Auto-generated' }, - { var: 'BETTER_AUTH_URL', desc: 'Authentication origin (scheme + host, no path). Any path is stripped automatically.', default: 'http://localhost:4321' }, - { var: 'NODE_EXTRA_CA_CERTS', desc: 'Path to CA certificate file', default: 'None' }, - { var: 'DATABASE_URL', desc: 'SQLite database path', default: './data/gitea-mirror.db' }, - ].map((item, i) => ( - - - - - - ))} - -
VariableDescriptionDefault
{item.var}{item.desc}{item.default}
-
-
- -
- - -
-

Database Management

- -

- Gitea Mirror uses SQLite for data storage. The database is automatically created on first run. -

- -

Database Commands

- -
-
-

Initialize Database

-
- bun run init-db -
-

Creates or recreates the database schema

-
- -
-

Check Database

-
- bun run check-db -
-

Verifies database integrity and displays statistics

-
- -
-

Fix Database

-
- bun run fix-db -
-

Attempts to repair common database issues

-
- -
-

Backup Database

-
- cp data/gitea-mirror.db data/gitea-mirror.db.backup -
-

Always backup before major changes

-
-
- -

Database Schema Management

- -
-
-
- - - -
-
-

Drizzle Kit

-

Database schema is managed with Drizzle ORM. Use these commands for schema changes:

-
    -
  • bun run drizzle-kit generate - Generate migration files
  • -
  • bun run drizzle-kit push - Apply schema changes directly
  • -
  • bun run drizzle-kit studio - Open database browser
  • -
-
-
-
-
- -
- - -
-

Performance Optimization

- -

Mirroring Performance

- -
- {[ - { - title: 'Batch Operations', - tips: [ - 'Mirror multiple repositories at once', - 'Use organization-level mirroring', - 'Schedule mirroring during off-peak hours' - ] - }, - { - title: 'Network Optimization', - tips: [ - 'Use SSH URLs when possible', - 'Enable Git LFS only when needed', - 'Consider repository size limits' - ] - } - ].map(section => ( -
-

{section.title}

-
    - {section.tips.map(tip => ( -
  • - โ€ข - {tip} -
  • - ))} -
-
- ))} -
- -

Database Performance

- -
-

Regular Maintenance

-
    -
  • - โ€ข - Enable automatic cleanup in Configuration โ†’ Automation -
  • -
  • - โ€ข - Periodically vacuum the SQLite database: sqlite3 data/gitea-mirror.db "VACUUM;" -
  • -
  • - โ€ข - Monitor database size and clean old events regularly -
  • -
-
-
- -
- - -
-

Reverse Proxy Configuration

- -

- For production deployments, it's recommended to use a reverse proxy like Nginx or Caddy. -

- -
-
-
- - - -
-
-

Required Environment Variables for Reverse Proxy

-

- When running Gitea Mirror behind a reverse proxy, you must set these environment variables to your external URL. - Without them, sign-in will fail with "invalid origin" errors and pages may appear blank. -

-
-
{`# All three MUST be set to your external URL:
-BETTER_AUTH_URL=https://gitea-mirror.example.com
-PUBLIC_BETTER_AUTH_URL=https://gitea-mirror.example.com
-BETTER_AUTH_TRUSTED_ORIGINS=https://gitea-mirror.example.com`}
-
-
-
{`# If deployed under a path prefix (example: /mirror):
-# BASE_URL handles the path โ€” auth URLs stay as origin only
-BASE_URL=/mirror
-BETTER_AUTH_URL=https://git.example.com
-PUBLIC_BETTER_AUTH_URL=https://git.example.com
-BETTER_AUTH_TRUSTED_ORIGINS=https://git.example.com
-# โ†’ Auth endpoints resolve to: https://git.example.com/mirror/api/auth/*`}
-
-
    -
  • BASE_URL โ€” Application base path for path-prefix deployments (e.g. /mirror). This is handled separately from the auth URLs.
  • -
  • BETTER_AUTH_URL โ€” Server-side auth origin, scheme + host only (e.g. https://git.example.com). Do not include the base path โ€” it is applied automatically from BASE_URL.
  • -
  • PUBLIC_BETTER_AUTH_URL โ€” Client-side (browser) auth origin. Same rule: origin only, no path.
  • -
  • BETTER_AUTH_TRUSTED_ORIGINS โ€” Comma-separated origins allowed to make auth requests
  • -
-
-
-
- -

Docker Compose Example

- -
-
{`services:
-  gitea-mirror:
-    image: ghcr.io/raylabshq/gitea-mirror:latest
-    environment:
-      - BETTER_AUTH_SECRET=your-secret-key-min-32-chars
-      - BASE_URL=/mirror
-      - BETTER_AUTH_URL=https://git.example.com
-      - PUBLIC_BETTER_AUTH_URL=https://git.example.com
-      - BETTER_AUTH_TRUSTED_ORIGINS=https://git.example.com
-      # ... other settings ...`}
-
- -

Nginx Example

- -
-
{`server {
-    listen 80;
-    server_name gitea-mirror.example.com;
-    return 301 https://$server_name$request_uri;
-}
-
-server {
-    listen 443 ssl http2;
-    server_name gitea-mirror.example.com;
-
-    ssl_certificate /path/to/cert.pem;
-    ssl_certificate_key /path/to/key.pem;
-
-    location / {
-        proxy_pass http://localhost:4321;
-        proxy_http_version 1.1;
-        proxy_set_header Upgrade $http_upgrade;
-        proxy_set_header Connection 'upgrade';
-        proxy_set_header Host $host;
-        proxy_cache_bypass $http_upgrade;
-        proxy_set_header X-Real-IP $remote_addr;
-        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-        proxy_set_header X-Forwarded-Proto $scheme;
-    }
-
-    # SSE endpoint needs special handling
-    location /api/sse {
-        proxy_pass http://localhost:4321;
-        proxy_http_version 1.1;
-        proxy_set_header Connection '';
-        proxy_set_header Cache-Control 'no-cache';
-        proxy_set_header X-Accel-Buffering 'no';
-        proxy_set_header Host $host;
-        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-        proxy_set_header X-Forwarded-Proto $scheme;
-        proxy_read_timeout 86400;
-    }
-}`}
-
- -

Caddy Example

- -
-
{`gitea-mirror.example.com {
-    reverse_proxy localhost:4321
-}`}
-
-
- -
- - -
-

Monitoring and Health Checks

- -

Health Check Endpoint

- -
-

Monitor application health using the built-in endpoint:

- -
- GET /api/health -
- -

Response:

-
-
{`{
-  "status": "ok",
-  "timestamp": "2024-01-15T10:30:00Z",
-  "database": "connected",
-  "version": "1.0.0"
-}`}
-
-
- -

Monitoring with Prometheus

- -

- While Gitea Mirror doesn't have built-in Prometheus metrics, you can monitor it using: -

- -
    -
  • - โ€ข - Blackbox exporter for endpoint monitoring -
  • -
  • - โ€ข - Node exporter for system metrics -
  • -
  • - โ€ข - Custom scripts to check database metrics -
  • -
-
- -
- - -
-

Backup and Recovery

- -

What to Backup

- -
-
-

Essential Files

-
    -
  • โ€ข data/gitea-mirror.db
  • -
  • โ€ข .env (if using)
  • -
  • โ€ข Custom CA certificates
  • -
-
- -
-

Optional Files

-
    -
  • โ€ข Docker volumes
  • -
  • โ€ข Custom configurations
  • -
  • โ€ข Logs for auditing
  • -
-
-
- -

Backup Script Example

- -
-
{`#!/bin/bash
-BACKUP_DIR="/backups/gitea-mirror"
-DATE=$(date +%Y%m%d_%H%M%S)
-
-# Create backup directory
-mkdir -p "$BACKUP_DIR/$DATE"
-
-# Backup database
-cp data/gitea-mirror.db "$BACKUP_DIR/$DATE/"
-
-# Backup environment
-cp .env "$BACKUP_DIR/$DATE/" 2>/dev/null || true
-
-# Create tarball
-tar -czf "$BACKUP_DIR/backup_$DATE.tar.gz" -C "$BACKUP_DIR" "$DATE"
-
-# Clean up
-rm -rf "$BACKUP_DIR/$DATE"
-
-# Keep only last 7 backups
-ls -t "$BACKUP_DIR"/backup_*.tar.gz | tail -n +8 | xargs rm -f`}
-
-
- -
- - -
-

Troubleshooting Guide

- -
- {[ - { - issue: 'Application won\'t start', - solutions: [ - 'Check port availability: `lsof -i :4321`', - 'Verify environment variables are set correctly', - 'Check database file permissions', - 'Review logs for startup errors' - ] - }, - { - issue: 'Authentication failures', - solutions: [ - 'Ensure BETTER_AUTH_SECRET is set and consistent', - 'Check BETTER_AUTH_URL matches your deployment', - 'Clear browser cookies and try again', - 'Verify database contains user records' - ] - }, - { - issue: 'Mirroring failures', - solutions: [ - 'Test GitHub/Gitea connections individually', - 'Verify access tokens have correct permissions', - 'Check network connectivity and firewall rules', - 'Review Activity Log for detailed error messages' - ] - }, - { - issue: 'Performance issues', - solutions: [ - 'Check database size and run cleanup', - 'Monitor system resources (CPU, memory, disk)', - 'Reduce concurrent mirroring operations', - 'Consider upgrading deployment resources' - ] - } - ].map(item => ( -
-

{item.issue}

-
    - {item.solutions.map(solution => ( -
  • - โ†’ - {solution} -
  • - ))} -
-
- ))} -
-
- -
- - -
-

Migration Guide

- -

Migrating from JWT to Better Auth

- -
-

If you're upgrading from an older version using JWT authentication:

- -
    -
  1. - 1 -
    - Backup your database -

    Always create a backup before migration

    -
    -
  2. -
  3. - 2 -
    - Update environment variables -

    Replace JWT_SECRET with BETTER_AUTH_SECRET

    -
    -
  4. -
  5. - 3 -
    - Run database migrations -

    New auth tables will be created automatically

    -
    -
  6. -
  7. - 4 -
    - Users will need to log in again -

    Previous sessions will be invalidated

    -
    -
  8. -
-
-
-
-
- diff --git a/src/pages/docs/architecture.astro b/src/pages/docs/architecture.astro deleted file mode 100644 index 087a6a7..0000000 --- a/src/pages/docs/architecture.astro +++ /dev/null @@ -1,340 +0,0 @@ ---- -import MainLayout from '../../layouts/main.astro'; -import { withBase } from '@/lib/base-path'; ---- - - -
- - -
- -
-
- - - - Architecture Overview -
-

Gitea Mirror Architecture

-

- This document provides a comprehensive overview of the Gitea Mirror application architecture, including component diagrams, project structure, and detailed explanations of each part of the system. -

-
- - -
-

System Overview

- -
-

- Gitea Mirror is a web application that automates the mirroring of GitHub repositories to Gitea instances. It provides a user-friendly interface for configuring, monitoring, and managing mirroring operations without requiring users to edit configuration files or run Docker commands. -

- -
-

Technology Stack

-
- {[ - { name: 'Astro', desc: 'Web framework for Server-Side Rendering (SSR)' }, - { name: 'React', desc: 'Component library for interactive UI elements' }, - { name: 'Tailwind CSS v4', desc: 'Utility-first CSS framework (with Vite plugin)' }, - { name: 'Shadcn UI', desc: 'UI component library built on Tailwind CSS' }, - { name: 'SQLite', desc: 'Database for storing configuration, state, and events' }, - { name: 'Bun', desc: 'JavaScript runtime and package manager' }, - { name: 'Drizzle ORM', desc: 'Type-safe ORM for database interactions' }, - { name: 'Better Auth', desc: 'Modern authentication library with SSO/OIDC support' } - ].map(tech => ( -
-
-
- {tech.name} -

{tech.desc}

-
-
- ))} -
-
-
-
- -
- - -
-

Architecture Diagram

- -
-
-
- -
-

Gitea Mirror System

- -
- {[ - { icon: '๐ŸŽจ', name: 'Frontend', tech: 'Astro + React' }, - { icon: 'โš™๏ธ', name: 'Backend', tech: 'Bun Runtime' }, - { icon: '๐Ÿ—„๏ธ', name: 'Database', tech: 'SQLite + Drizzle' } - ].map((component, index) => ( - <> -
-
{component.icon}
-

{component.name}

-

{component.tech}

-
- {index < 2 && ( -
-
- - - -
-
- )} - - ))} -
-
- - -
-
-

External APIs

- -
-
-
๐Ÿ™
-

GitHub API

-

Repository Data Source

-
- -
-
๐Ÿต
-

Gitea API

-

Mirror Destination

-
-
-
- -
-
-
Data Flow
-
- Backend - - - - APIs -
-
-
-
-
-
-
-
- -
- - -
-

Component Breakdown

- - -
-

Frontend (Astro + React)

-
-

- The frontend is built with Astro, a modern web framework that allows for server-side rendering and partial hydration. React components are used for interactive elements, providing a responsive and dynamic user interface. -

- -

Key Frontend Components

-
- {[ - { name: 'Dashboard', desc: 'Overview of mirroring status and recent activity' }, - { name: 'Repository Management', desc: 'Interface for managing repositories to mirror' }, - { name: 'Organization Management', desc: 'Interface for managing GitHub organizations' }, - { name: 'Configuration', desc: 'Settings for GitHub and Gitea connections' }, - { name: 'Activity Log', desc: 'Detailed log of mirroring operations' } - ].map(component => ( -
- โ–ธ -
- {component.name} -

{component.desc}

-
-
- ))} -
-
-
- - -
-

Backend (Bun)

-
-

- The backend is built with Bun and provides API endpoints for the frontend to interact with. It handles: -

- -
- {[ - 'Authentication with Better Auth (email/password, SSO, OIDC)', - 'OAuth2/OIDC provider functionality', - 'GitHub API integration', - 'Gitea API integration', - 'Mirroring operations and job queue', - 'Real-time updates via Server-Sent Events (SSE) at /api/sse/', - 'Job recovery system for interrupted operations', - 'Graceful shutdown handling', - 'Scheduled automatic mirroring', - 'Database interactions with Drizzle ORM' - ].map(item => ( -
- โ–ธ - {item} -
- ))} -
-
-
- - -
-

Database (SQLite + Drizzle ORM)

-
-

- SQLite with Bun's native SQLite driver is used for data persistence, with Drizzle ORM providing type-safe database interactions. The database stores: -

- -
- {[ - 'User accounts and authentication data (Better Auth)', - 'OAuth applications and SSO provider configurations', - 'GitHub and Gitea configuration', - 'Repository and organization information', - 'Mirroring job history and status', - 'Event notifications and their read status', - 'OAuth tokens and consent records' - ].map(item => ( -
- โ–ธ - {item} -
- ))} -
-
-
-
- -
- - -
-

Data Flow

- -
-
    - {[ - { title: 'User Authentication', desc: 'Users authenticate via Better Auth using email/password, SSO providers, or as OIDC clients.' }, - { title: 'Configuration', desc: 'Users configure GitHub and Gitea settings through the UI, which are stored in the SQLite database.' }, - { title: 'Repository Discovery', desc: 'The backend queries the GitHub API to discover repositories based on user configuration.' }, - { title: 'Mirroring Process', desc: 'When triggered, the backend fetches repository data from GitHub and pushes it to Gitea.' }, - { title: 'Status Tracking', desc: 'All operations are logged in the database and displayed in the Activity Log.' } - ].map((step, index) => ( -
  1. - - {index + 1} - -
    - {step.title} -

    {step.desc}

    -
    -
  2. - ))} -
-
-
- -
- - -
-

Project Structure

- -
-
{`gitea-mirror/
-โ”œโ”€โ”€ src/                  # Source code
-โ”‚   โ”œโ”€โ”€ components/       # React components
-โ”‚   โ”œโ”€โ”€ content/          # Documentation and content
-โ”‚   โ”œโ”€โ”€ layouts/          # Astro layout components
-โ”‚   โ”œโ”€โ”€ lib/              # Utility functions and database
-โ”‚   โ”œโ”€โ”€ pages/            # Astro pages and API routes
-โ”‚   โ””โ”€โ”€ styles/           # CSS and Tailwind styles
-โ”œโ”€โ”€ public/               # Static assets
-โ”œโ”€โ”€ data/                 # Database and persistent data
-โ”œโ”€โ”€ docker/               # Docker configuration
-โ””โ”€โ”€ scripts/              # Utility scripts for deployment and maintenance
-    โ”œโ”€โ”€ gitea-mirror-lxc-local.sh    # Local LXC deployment script
-    โ””โ”€โ”€ manage-db.ts                 # Database management tool`}
-
-
- -
- - -
-

Deployment Options

- -

Gitea Mirror supports multiple deployment options:

- -
- {[ - { icon: '๐Ÿณ', name: 'Docker', desc: 'Run as a containerized application using Docker and docker-compose' }, - { icon: '๐Ÿ“ฆ', name: 'LXC Containers', desc: 'Deploy in Linux Containers on Proxmox VE using community script' }, - { icon: '๐Ÿƒ', name: 'Native', desc: 'Run directly on the host system using Bun runtime' } - ].map(option => ( -
-
-
{option.icon}
-
-

{option.name}

-

{option.desc}

-
-
-
- ))} -
- -
-

Deployment Advantages

-
-
- Docker: - Isolation, easy updates, consistent environment -
-
- LXC: - Lightweight virtualization, better performance than Docker, system-level isolation -
-
- Native: - Best performance, direct access to system resources -
-
-
- -
-

Note: LXC deployment is available through the Proxmox VE Community Scripts project.

-
-
-
-
-
\ No newline at end of file diff --git a/src/pages/docs/authentication.astro b/src/pages/docs/authentication.astro deleted file mode 100644 index 4de4afe..0000000 --- a/src/pages/docs/authentication.astro +++ /dev/null @@ -1,536 +0,0 @@ ---- -import MainLayout from '../../layouts/main.astro'; -import { withBase } from '@/lib/base-path'; ---- - - -
- - -
- -
-
- - - - Authentication -
-

Authentication & SSO Configuration

-

- Configure authentication methods including email/password, Single Sign-On (SSO), and OIDC provider functionality for Gitea Mirror. -

-
- - -
-

Authentication Overview

- -
-

- Gitea Mirror uses Better Auth, a modern authentication library that supports multiple authentication methods. - All authentication settings can be configured through the web UI without editing configuration files. -

-
- -

Supported Authentication Methods

- -
- {[ - { - icon: 'โœ‰๏ธ', - title: 'Email & Password', - desc: 'Traditional authentication with email and password. Always enabled by default.', - status: 'Always Enabled' - }, - { - icon: '๐ŸŒ', - title: 'Single Sign-On (SSO)', - desc: 'Allow users to sign in using external OIDC providers like Google, Okta, or Azure AD.', - status: 'Optional' - }, - { - icon: '๐Ÿ”‘', - title: 'OIDC Provider', - desc: 'Act as an OIDC provider, allowing other applications to authenticate through Gitea Mirror.', - status: 'Optional' - } - ].map(method => ( -
-
{method.icon}
-

{method.title}

-

{method.desc}

- - {method.status} - -
- ))} -
-
- -
- - -
-

Accessing Authentication Settings

- -
    -
  1. - 1 - Navigate to the Configuration page -
  2. -
  3. - 2 - Click on the Authentication tab -
  4. -
  5. - 3 - Configure SSO providers or OAuth applications as needed -
  6. -
-
- -
- - -
-

Single Sign-On (SSO) Configuration

- -

- SSO allows your users to authenticate using external identity providers. This is useful for organizations that already have centralized authentication systems. -

- -

Adding an SSO Provider

- -
-

Required Information

- -
- {[ - { name: 'Issuer URL', desc: 'The OIDC issuer URL of your provider', example: 'https://accounts.google.com' }, - { name: 'Domain', desc: 'The email domain for this provider', example: 'example.com' }, - { name: 'Provider ID', desc: 'A unique identifier for this provider', example: 'google-sso' }, - { name: 'Client ID', desc: 'OAuth client ID from your provider', example: '123456789.apps.googleusercontent.com' }, - { name: 'Client Secret', desc: 'OAuth client secret from your provider', example: 'GOCSPX-...' } - ].map(field => ( -
-
- {field.name} - Required -
-

{field.desc}

- {field.example} -
- ))} -
-
- -
-
-
- - - -
-
-

Auto-Discovery

-

Most OIDC providers support auto-discovery. Simply enter the Issuer URL and click "Discover" to automatically populate the endpoint URLs.

-
-
-
- -

Redirect URL Configuration

- -
-

When configuring your SSO provider, use this redirect URL:

- https://your-domain.com/api/auth/sso/callback/{`{provider-id}`} -

Replace {`{provider-id}`} with your chosen Provider ID (e.g., google-sso)

-
-
- -
- - -
-

Example SSO Configurations

- - -
-

- Google - Google SSO -

- -
-
    -
  1. - 1. Create OAuth Client in Google Cloud Console -
      -
    • โ€ข Go to Google Cloud Console
    • -
    • โ€ข Create a new OAuth 2.0 Client ID
    • -
    • โ€ข Add authorized redirect URI: https://your-domain.com/api/auth/sso/callback/google-sso
    • -
    -
  2. -
  3. - 2. Configure in Gitea Mirror -
    -
    -
    Issuer URL: https://accounts.google.com
    -
    Domain: your-company.com
    -
    Provider ID: google-sso
    -
    Client ID: [Your Google Client ID]
    -
    Client Secret: [Your Google Client Secret]
    -
    -
    -
  4. -
  5. - 3. Use Auto-Discovery -

    Click "Discover" to automatically populate the endpoint URLs

    -
  6. -
-
-
- - -
-

- O - Okta SSO -

- -
-
    -
  1. - 1. Create OIDC Application in Okta -
      -
    • โ€ข In Okta Admin Console, create a new OIDC Web Application
    • -
    • โ€ข Set Sign-in redirect URI: https://your-domain.com/api/auth/sso/callback/okta-sso
    • -
    • โ€ข Note the Client ID and Client Secret
    • -
    -
  2. -
  3. - 2. Configure in Gitea Mirror -
    -
    -
    Issuer URL: https://your-okta-domain.okta.com
    -
    Domain: your-company.com
    -
    Provider ID: okta-sso
    -
    Client ID: [Your Okta Client ID]
    -
    Client Secret: [Your Okta Client Secret]
    -
    -
    -
  4. -
-
-
- - -
-

- M - Azure AD / Microsoft Entra ID -

- -
-
    -
  1. - 1. Register Application in Azure Portal -
      -
    • โ€ข Go to Azure Portal โ†’ Azure Active Directory โ†’ App registrations
    • -
    • โ€ข Create a new registration
    • -
    • โ€ข Add redirect URI: https://your-domain.com/api/auth/sso/callback/azure-sso
    • -
    -
  2. -
  3. - 2. Configure in Gitea Mirror -
    -
    -
    Issuer URL: https://login.microsoftonline.com/{`{tenant-id}`}/v2.0
    -
    Domain: your-company.com
    -
    Provider ID: azure-sso
    -
    Client ID: [Your Application ID]
    -
    Client Secret: [Your Client Secret]
    -
    -
    -
  4. -
-
-
-
- -
- - -
-

OIDC Provider Configuration

- -

- The OIDC Provider feature allows Gitea Mirror to act as an authentication provider for other applications. - This is useful when you want to centralize authentication through Gitea Mirror. -

- -

Creating OAuth Applications

- -
-
    -
  1. - 1 -
    - Navigate to OAuth Applications -

    Go to Configuration โ†’ Authentication โ†’ OAuth Applications

    -
    -
  2. -
  3. - 2 -
    - Create New Application -

    Click "Create Application" and provide:

    -
      -
    • โ€ข Application Name
    • -
    • โ€ข Application Type (Web, Mobile, or Desktop)
    • -
    • โ€ข Redirect URLs (one per line)
    • -
    -
    -
  4. -
  5. - 3 -
    - Save Credentials -

    You'll receive a Client ID and Client Secret. Store these securely!

    -
    -
  6. -
-
- -

OIDC Endpoints

- -
-

Applications can use these standard OIDC endpoints:

-
-
- Discovery: - https://your-domain.com/.well-known/openid-configuration -
-
- Authorization: - https://your-domain.com/api/auth/oauth2/authorize -
-
- Token: - https://your-domain.com/api/auth/oauth2/token -
-
- UserInfo: - https://your-domain.com/api/auth/oauth2/userinfo -
-
- JWKS: - https://your-domain.com/api/auth/jwks -
-
-
- -

Supported Scopes

- -
- {[ - { scope: 'openid', desc: 'Required - provides user ID', claims: 'sub' }, - { scope: 'profile', desc: 'User profile information', claims: 'name, username, picture' }, - { scope: 'email', desc: 'Email address', claims: 'email, email_verified' } - ].map(item => ( -
- {item.scope} -

{item.desc}

-

Claims: {item.claims}

-
- ))} -
-
- -
- - -
-

User Experience

- -

Login Flow with SSO

- -
-

When SSO is configured, users will see authentication options on the login page:

-
    -
  1. 1. Email & Password tab for traditional login
  2. -
  3. 2. SSO tab with provider buttons or email input
  4. -
  5. 3. Automatic redirect to the appropriate provider
  6. -
  7. 4. Return to Gitea Mirror after successful authentication
  8. -
-
- -

OAuth Consent Flow

- -
-

When an application requests authentication through Gitea Mirror:

-
    -
  1. 1. User is redirected to Gitea Mirror
  2. -
  3. 2. Login prompt if not already authenticated
  4. -
  5. 3. Consent screen showing requested permissions
  6. -
  7. 4. User approves or denies the request
  8. -
  9. 5. Redirect back to the application with auth code
  10. -
-
-
- -
- - -
-

Security Considerations

- -
- {[ - { - icon: '๐Ÿ”’', - title: 'Client Secrets', - items: [ - 'Store OAuth client secrets securely', - 'Never commit secrets to version control', - 'Rotate secrets regularly' - ] - }, - { - icon: '๐Ÿ”—', - title: 'Redirect URLs', - items: [ - 'Only add trusted redirect URLs', - 'Use HTTPS in production', - 'Validate exact URL matches' - ] - }, - { - icon: '๐Ÿ›ก๏ธ', - title: 'Scopes & Permissions', - items: [ - 'Grant minimum required scopes', - 'Review requested permissions', - 'Users can revoke access anytime' - ] - }, - { - icon: 'โฑ๏ธ', - title: 'Token Security', - items: [ - 'Access tokens have expiration', - 'Refresh tokens for long-lived access', - 'Tokens can be revoked' - ] - } - ].map(section => ( -
-
- {section.icon} -

{section.title}

-
-
    - {section.items.map(item => ( -
  • - โ€ข - {item} -
  • - ))} -
-
- ))} -
-
- -
- - -
-

Troubleshooting

- -
-
-

SSO Login Issues

-
    -
  • - โ€ข -
    - "Invalid origin" error: Check that your Gitea Mirror URL matches the configured redirect URI -
    -
  • -
  • - โ€ข -
    - "Provider not found" error: Ensure the provider is properly configured and saved -
    -
  • -
  • - โ€ข -
    - Redirect loop: Verify the redirect URI in both Gitea Mirror and the SSO provider match exactly -
    -
  • -
-
- -
-

OIDC Provider Issues

-
    -
  • - โ€ข -
    - Application not found: Ensure the client ID is correct and the app is not disabled -
    -
  • -
  • - โ€ข -
    - Invalid redirect URI: The redirect URI must match exactly what's configured -
    -
  • -
  • - โ€ข -
    - Consent not working: Check browser cookies are enabled and not blocked -
    -
  • -
-
-
-
- -
- - -
-

Migration from JWT Authentication

- -
-
-
- - - -
-
-

For Existing Users

-
    -
  • โ€ข Email/password authentication continues to work
  • -
  • โ€ข No action required from existing users
  • -
  • โ€ข SSO can be added as an additional option
  • -
  • โ€ข JWT_SECRET is no longer required in environment variables
  • -
-
-
-
-
-
-
-
\ No newline at end of file diff --git a/src/pages/docs/ca-certificates.astro b/src/pages/docs/ca-certificates.astro deleted file mode 100644 index 9078547..0000000 --- a/src/pages/docs/ca-certificates.astro +++ /dev/null @@ -1,476 +0,0 @@ ---- -import MainLayout from '../../layouts/main.astro'; -import { withBase } from '@/lib/base-path'; ---- - - -
- - -
- -
-
- - - - Security -
-

CA Certificates Configuration

-

- Configure custom Certificate Authority (CA) certificates for connecting to self-signed or privately signed Gitea instances. -

-
- - -
-

Overview

- -
-

- When your Gitea instance uses a self-signed certificate or a certificate signed by a private Certificate Authority (CA), - you need to configure Gitea Mirror to trust these certificates. This guide explains how to add custom CA certificates - for different deployment methods. -

-
- -
-
-
- - - -
-
-

Important

-

Without proper CA certificate configuration, you'll encounter SSL/TLS errors when connecting to Gitea instances with custom certificates.

-
-
-
-
- -
- - -
-

Common SSL/TLS Errors

- -

If you see any of these errors, you likely need to configure CA certificates:

- -
- {[ - 'UNABLE_TO_VERIFY_LEAF_SIGNATURE', - 'SELF_SIGNED_CERT_IN_CHAIN', - 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY', - 'CERT_UNTRUSTED', - 'unable to verify the first certificate' - ].map(error => ( -
- {error} -
- ))} -
-
- -
- - -
-

Docker Configuration

- -

For Docker deployments, you have several options to add custom CA certificates:

- -

Method 1: Volume Mount (Recommended)

- -
-
    -
  1. - 1. Create a certificates directory -
    -
    mkdir -p ./certs
    -
    -
  2. -
  3. - 2. Copy your CA certificate(s) -
    -
    cp /path/to/your-ca-cert.crt ./certs/
    -
    -
  4. -
  5. - 3. Update docker-compose.yml -
    -
    {`version: '3.8'
    -services:
    -  gitea-mirror:
    -    image: raylabs/gitea-mirror:latest
    -    volumes:
    -      - ./data:/app/data
    -      - ./certs:/usr/local/share/ca-certificates:ro
    -    environment:
    -      - NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/your-ca-cert.crt`}
    -
    -
  6. -
  7. - 4. Restart the container -
    -
    docker-compose down && docker-compose up -d
    -
    -
  8. -
-
- -

Method 2: Custom Docker Image

- -
-

For permanent certificate inclusion, create a custom Docker image:

- -
-
{`FROM raylabs/gitea-mirror:latest
-
-# Copy CA certificates
-COPY ./certs/*.crt /usr/local/share/ca-certificates/
-
-# Update CA certificates
-RUN update-ca-certificates
-
-# Set environment variable
-ENV NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/your-ca-cert.crt`}
-
- -

Build and use your custom image:

-
-
docker build -t my-gitea-mirror .
-
-
-
- -
- - -
-

Native/Bun Configuration

- -

For native Bun deployments, configure CA certificates using environment variables:

- -

Method 1: Environment Variable

- -
-
    -
  1. - 1. Export the certificate path -
    -
    export NODE_EXTRA_CA_CERTS=/path/to/your-ca-cert.crt
    -
    -
  2. -
  3. - 2. Run Gitea Mirror -
    -
    bun run start
    -
    -
  4. -
-
- -

Method 2: .env File

- -
-

Add to your .env file:

-
-
NODE_EXTRA_CA_CERTS=/path/to/your-ca-cert.crt
-
-
- -

Method 3: System-wide CA Store

- -
-

Add certificates to your system's CA store:

- -
-
- Ubuntu/Debian: -
-
{`sudo cp your-ca-cert.crt /usr/local/share/ca-certificates/
-sudo update-ca-certificates`}
-
-
- -
- RHEL/CentOS/Fedora: -
-
{`sudo cp your-ca-cert.crt /etc/pki/ca-trust/source/anchors/
-sudo update-ca-trust`}
-
-
- -
- macOS: -
-
{`sudo security add-trusted-cert -d -r trustRoot \\
-  -k /Library/Keychains/System.keychain your-ca-cert.crt`}
-
-
-
-
-
- -
- - -
-

LXC Container Configuration

- -

For LXC deployments on Proxmox VE:

- -
-
    -
  1. - 1. Enter the container -
    -
    pct enter <container-id>
    -
    -
  2. -
  3. - 2. Create certificates directory -
    -
    mkdir -p /usr/local/share/ca-certificates
    -
    -
  4. -
  5. - 3. Copy your CA certificate -
    -
    cat > /usr/local/share/ca-certificates/your-ca.crt
    -
    -

    Paste your certificate content and press Ctrl+D

    -
  6. -
  7. - 4. Update the systemd service -
    -
    {`cat >> /etc/systemd/system/gitea-mirror.service << EOF
    -Environment="NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/your-ca.crt"
    -EOF`}
    -
    -
  8. -
  9. - 5. Reload and restart -
    -
    {`systemctl daemon-reload
    -systemctl restart gitea-mirror`}
    -
    -
  10. -
-
-
- -
- - -
-

Multiple CA Certificates

- -

If you need to trust multiple CA certificates:

- -

Option 1: Bundle Certificates

- -
-

Combine multiple certificates into one file:

-
-
{`cat ca-cert1.crt ca-cert2.crt ca-cert3.crt > ca-bundle.crt
-export NODE_EXTRA_CA_CERTS=/path/to/ca-bundle.crt`}
-
-
- -

Option 2: System CA Store

- -
-

Add all certificates to the system CA store (recommended for production):

-
-
{`# Copy all certificates
-cp *.crt /usr/local/share/ca-certificates/
-update-ca-certificates`}
-
-
-
- -
- - -
-

Verifying Certificate Configuration

- -

Test your certificate configuration:

- -
-

1. Test Gitea Connection

-

Use the "Test Connection" button in the Gitea configuration section

- -

2. Check Logs

-

Look for SSL/TLS errors in the application logs:

- -
-
- Docker: -
- docker logs gitea-mirror -
-
-
- Native: -
- Check terminal output -
-
-
- LXC: -
- journalctl -u gitea-mirror -f -
-
-
- -

3. Manual Certificate Test

-

Test SSL connection directly:

-
-
openssl s_client -connect your-gitea-domain.com:443 -CAfile /path/to/ca-cert.crt
-
-
-
- -
- - -
-

Best Practices

- -
- {[ - { - icon: '๐Ÿ”’', - title: 'Certificate Security', - items: [ - 'Keep CA certificates secure', - 'Use read-only mounts in Docker', - 'Limit certificate file permissions', - 'Regularly update certificates' - ] - }, - { - icon: '๐Ÿ“', - title: 'Certificate Management', - items: [ - 'Use descriptive certificate filenames', - 'Document certificate purposes', - 'Track certificate expiration dates', - 'Maintain certificate backups' - ] - }, - { - icon: '๐Ÿข', - title: 'Production Deployment', - items: [ - 'Use proper SSL certificates when possible', - 'Consider Let\'s Encrypt for public instances', - 'Implement certificate rotation procedures', - 'Monitor certificate expiration' - ] - }, - { - icon: '๐Ÿ”', - title: 'Troubleshooting', - items: [ - 'Verify certificate format (PEM)', - 'Check certificate chain completeness', - 'Ensure proper file permissions', - 'Test with openssl commands' - ] - } - ].map(section => ( -
-
- {section.icon} -

{section.title}

-
-
    - {section.items.map(item => ( -
  • - โ€ข - {item} -
  • - ))} -
-
- ))} -
-
- -
- - -
-

Common Issues and Solutions

- -
-
-

Certificate not being recognized

-
    -
  • - โ€ข - Ensure the certificate is in PEM format -
  • -
  • - โ€ข - Check that NODE_EXTRA_CA_CERTS points to the correct file -
  • -
  • - โ€ข - Restart the application after adding certificates -
  • -
-
- -
-

Still getting SSL errors

-
    -
  • - โ€ข - Verify the complete certificate chain is included -
  • -
  • - โ€ข - Check if intermediate certificates are needed -
  • -
  • - โ€ข - Ensure the certificate matches the server hostname -
  • -
-
- -
-

Certificate expired

-
    -
  • - โ€ข - Check certificate validity: openssl x509 -in cert.crt -noout -dates -
  • -
  • - โ€ข - Update with new certificate from your CA -
  • -
  • - โ€ข - Restart Gitea Mirror after updating -
  • -
-
-
-
-
-
-
\ No newline at end of file diff --git a/src/pages/docs/configuration.astro b/src/pages/docs/configuration.astro deleted file mode 100644 index 00a9f0d..0000000 --- a/src/pages/docs/configuration.astro +++ /dev/null @@ -1,514 +0,0 @@ ---- -import MainLayout from '../../layouts/main.astro'; -import { withBase } from '@/lib/base-path'; - -const envVars = [ - { name: 'NODE_ENV', desc: 'Runtime environment', default: 'development', example: 'production' }, - { name: 'BASE_URL', desc: 'Application base path', default: '/', example: '/mirror' }, - { name: 'DATABASE_URL', desc: 'SQLite database URL', default: 'file:data/gitea-mirror.db', example: 'file:path/to/database.db' }, - { name: 'JWT_SECRET', desc: 'Secret key for JWT auth', default: 'Auto-generated', example: 'your-secure-string' }, - { name: 'HOST', desc: 'Server host', default: 'localhost', example: '0.0.0.0' }, - { name: 'PORT', desc: 'Server port', default: '4321', example: '8080' } -]; - -const githubOptions = [ - { name: 'Username', desc: 'Your GitHub username', default: '-' }, - { name: 'Token', desc: 'GitHub personal access token (Classic PAT)', default: '-' }, - { name: 'Private Repositories', desc: 'Include private repositories', default: 'false' }, - { name: 'Mirror Starred', desc: 'Mirror repositories you\'ve starred', default: 'false' }, - { name: 'Mirror Issues', desc: 'Mirror issues from GitHub to Gitea', default: 'false' }, - { name: 'Mirror Wiki', desc: 'Mirror wiki pages from GitHub to Gitea', default: 'false' }, - { name: 'Mirror Organizations', desc: 'Mirror organization repositories', default: 'false' }, - { name: 'Only Mirror Orgs', desc: 'Only mirror organization repositories', default: 'false' }, - { name: 'Skip Forks', desc: 'Exclude repositories that are forks', default: 'false' }, - { name: 'Skip Starred Issues', desc: 'Skip issues for starred repositories', default: 'false' } -]; - -const giteaOptions = [ - { name: 'URL', desc: 'Gitea server URL', default: '-' }, - { name: 'Token', desc: 'Gitea access token', default: '-' }, - { name: 'Organization', desc: 'Default organization for mirrored repositories', default: '-' }, - { name: 'Visibility', desc: 'Default visibility for mirrored repositories', default: 'public' }, - { name: 'Starred Repos Org', desc: 'Organization for starred repositories', default: 'github' } -]; ---- - - -
- - -
- -
-
- - - - - Configuration Guide -
-

Gitea Mirror Configuration

-

- This guide provides detailed information on how to configure Gitea Mirror for your environment. -

-
- - -
-

Configuration Methods

- -
-
-
-
๐Ÿ”ง
-
-

Environment Variables

-

Set configuration options through environment variables for automated deployments

-
-
-
- -
-
-
๐Ÿ–ฅ๏ธ
-
-

Web UI

-

Configure the application through the web interface after installation

-
-
-
-
-
- -
- - -
-

Environment Variables

- -

The following environment variables can be used to configure Gitea Mirror:

- -
- - - - - - - - - - - {envVars.map((v, i) => ( - - - - - - - ))} - -
VariableDescriptionDefaultExample
- {v.name} - {v.desc}{v.default}{v.example}
-
- - -
-
-
- - - -
-
-

Security Note

-

The application will automatically generate a secure random JWT_SECRET on first run if one isn't provided. This generated secret is stored in the data directory for persistence across container restarts.

-

While this auto-generation feature provides good security by default, you can still explicitly set your own JWT_SECRET for complete control over your deployment.

-
-
-
-
- -
- - -
-

Web UI Configuration

- -

After installing and starting Gitea Mirror, you can configure it through the web interface:

- -
-
    - {[ - 'Navigate to http://your-server:port/', - 'If this is your first time, you\'ll be guided through creating an admin account', - 'Log in with your credentials', - 'Go to the Configuration page' - ].map((step, i) => ( -
  1. - {i + 1} - -
  2. - ))} -
-
- - -
-

GitHub Connection

-

The GitHub configuration section allows you to connect to GitHub and specify which repositories to mirror.

- -
- - - - - - - - - - {githubOptions.map((opt, i) => ( - - - - - - ))} - -
OptionDescriptionDefault
{opt.name}{opt.desc}{opt.default}
-
- - -
-
-
- - - -
-
-

Required Permissions

-

You need to create a Classic GitHub PAT Token with the following scopes:

-
    -
  • - โ€ข - repo - Full control of private repositories -
  • -
  • - โ€ข - admin:org - Full control of orgs and teams, read and write org projects -
  • -
-

The organization access is required for mirroring organization repositories.

-
-
-
- -
-
To create a GitHub token:
-
    -
  1. Go to GitHub Settings > Developer settings > Personal access tokens
  2. -
  3. Click "Generate new token"
  4. -
  5. Select the required permissions
  6. -
  7. Copy the generated token and paste it into Gitea Mirror
  8. -
-
-
- - -
-

Gitea Connection

-

The Gitea configuration section allows you to connect to your Gitea instance and specify how repositories should be mirrored.

- -
- - - - - - - - - - {giteaOptions.map((opt, i) => ( - - - - - - ))} - -
OptionDescriptionDefault
{opt.name}{opt.desc}{opt.default}
-
- - -
-

Mirror Strategies

-

Choose how your repositories will be organized in Gitea:

- -
-
-
- ๐Ÿ“ - Preserve GitHub Structure -
-

Maintains the exact structure from GitHub:

-
    -
  • - โ€ข - Personal repos โ†’ Your Gitea username -
  • -
  • - โ€ข - Organization repos โ†’ Same organization name in Gitea -
  • -
-
- -
-
- ๐Ÿข - Single Organization -
-

Consolidates all repositories into one organization:

-
    -
  • - โ€ข - All repos โ†’ One designated organization -
  • -
  • - โ€ข - Requires setting "Organization" field -
  • -
-
- -
-
- ๐Ÿ‘ค - Flat User Structure -
-

Mirrors all repositories under your user account:

-
    -
  • - โ€ข - All repos โ†’ Your Gitea username -
  • -
  • - โ€ข - No organizations needed -
  • -
-
-
- -
-

- Note: Starred repositories are always mirrored to the "Starred Repos Org" (default: "starred") regardless of the chosen strategy. -

-
-
- -
-
To create a Gitea access token:
-
    -
  1. Log in to your Gitea instance
  2. -
  3. Go to Settings > Applications
  4. -
  5. Under "Generate New Token", enter a name for your token
  6. -
  7. Click "Generate Token"
  8. -
  9. Copy the generated token and paste it into Gitea Mirror
  10. -
-
-
- - -
-

Schedule Configuration

-

You can configure automatic mirroring on a schedule:

- -
- - - - - - - - - - - - - - - - - - - - -
OptionDescriptionDefault
Enable SchedulingEnable automatic mirroringfalse
Interval (seconds)Time between mirroring operations3600 (1 hour)
-
-
-
- -
- - -
-

Advanced Configuration

- - - -
-

Database Management

-

Gitea Mirror includes several database management tools that can be run from the command line:

- -
-
{`# Initialize the database (only if it doesn't exist)
-bun run init-db
-
-# Check database status
-bun run check-db
-
-# Fix database location issues
-bun run fix-db
-
-# Reset all users (for testing signup flow)
-bun run reset-users
-
-# Remove database files completely
-bun run cleanup-db`}
-
-
- - -
-

Event Management

-

Events in Gitea Mirror (such as repository mirroring operations) are stored in the SQLite database and can be viewed in the Activity Log page.

- -
-
-
- - - -
-
-

Event Management Features:

-
    -
  • - โ€ข - View all events with filtering by type, status, and search -
  • -
  • - โ€ข - Real-time updates via Server-Sent Events (SSE) -
  • -
  • - โ€ข - Clean up old events using the cleanup button in the Activity Log -
  • -
  • - โ€ข - Automatic cleanup with configurable retention period -
  • -
-
-
-
-
- - -
-

Automatic Recovery System

-

Gitea Mirror includes a robust recovery system that automatically handles interrupted operations:

- -
-
    -
  • - โœ“ -
    - Startup Recovery: -

    Automatically recovers interrupted jobs when the application starts

    -
    -
  • -
  • - โœ“ -
    - Graceful Shutdown: -

    Saves job state before shutting down to enable recovery on restart

    -
    -
  • -
  • - โœ“ -
    - Job State Persistence: -

    Stores mirror job progress in the database for resilience

    -
    -
  • -
- -
-

Manual recovery tools:

-
{`# Run startup recovery manually
-bun run startup-recovery
-
-# Fix interrupted jobs
-bun scripts/fix-interrupted-jobs.ts
-
-# Test recovery system
-bun run test-recovery`}
-
-
-
- - -
-

Health Check Endpoint

- -
-

System Health Monitoring

-

Gitea Mirror includes a built-in health check endpoint at /api/health that provides:

- -
    -
  • - โœ“ - System status and uptime -
  • -
  • - โœ“ - Database connectivity check -
  • -
  • - โœ“ - Memory usage statistics -
  • -
  • - โœ“ - Environment information -
  • -
- -
-
{`# Basic check (returns 200 OK if healthy)
-curl -I http://your-server:port/api/health
-
-# Detailed health information (JSON)
-curl http://your-server:port/api/health`}
-
-
-
-
-
-
-
diff --git a/src/pages/docs/index.astro b/src/pages/docs/index.astro index 5db1243..128ee2f 100644 --- a/src/pages/docs/index.astro +++ b/src/pages/docs/index.astro @@ -1,89 +1,5 @@ --- -import MainLayout from '../../layouts/main.astro'; -import { LuSettings, LuRocket, LuBookOpen, LuShield, LuKey, LuNetwork } from 'react-icons/lu'; -import { withBase } from '@/lib/base-path'; - -// Define our documentation pages directly -const docs = [ - { - slug: 'quickstart', - title: 'Quick Start Guide', - description: 'Get started with Gitea Mirror quickly.', - order: 1, - icon: LuRocket, - href: '/docs/quickstart' - }, - { - slug: 'configuration', - title: 'Configuration', - description: 'Guide to configuring Gitea Mirror for your environment.', - order: 2, - icon: LuSettings, - href: '/docs/configuration' - }, - { - slug: 'authentication', - title: 'Authentication & SSO', - description: 'Configure authentication methods, SSO providers, and OIDC.', - order: 3, - icon: LuKey, - href: '/docs/authentication' - }, - { - slug: 'architecture', - title: 'Architecture', - description: 'Comprehensive overview of the Gitea Mirror application architecture.', - order: 4, - icon: LuBookOpen, - href: '/docs/architecture' - }, - { - slug: 'ca-certificates', - title: 'CA Certificates', - description: 'Configure custom CA certificates for self-signed Gitea instances.', - order: 5, - icon: LuShield, - href: '/docs/ca-certificates' - }, - { - slug: 'advanced', - title: 'Advanced Topics', - description: 'Advanced configuration, troubleshooting, and deployment options.', - order: 6, - icon: LuNetwork, - href: '/docs/advanced' - } -]; - -// Sort by order -const sortedDocs = docs.sort((a, b) => a.order - b.order); +// The documentation moved to the website. This stub keeps old bookmarks +// working; the offline reference lives in the repo's docs/ directory. +return Astro.redirect("https://gitea-mirror.raylabs.io/docs/"); --- - - -
-

Gitea Mirror Documentation

-

Browse guides and technical docs for Gitea Mirror.

- -
- {sortedDocs.map(doc => { - const Icon = doc.icon; - - return ( - -
-
- -
-

{doc.title}

-
-

{doc.description}

-
- ); - })} -
-
-
diff --git a/src/pages/docs/quickstart.astro b/src/pages/docs/quickstart.astro deleted file mode 100644 index c541a83..0000000 --- a/src/pages/docs/quickstart.astro +++ /dev/null @@ -1,438 +0,0 @@ ---- -import MainLayout from '../../layouts/main.astro'; -import { withBase } from '@/lib/base-path'; ---- - - -
- - -
- -
-
- - - - Quick Start -
-

Gitea Mirror Quick Start Guide

-

- This guide will help you get Gitea Mirror up and running quickly. -

-
- - -
-

Prerequisites

- -
-

Before you begin, make sure you have:

- -
-
-
1
-
- A GitHub account with a personal access token -

Create one at GitHub Settings

-
-
- -
-
2
-
- A Gitea instance with an access token -

Available in your Gitea Settings > Applications

-
-
- -
-
3
-
- One of the following: -
    -
  • โ€ข Docker and docker-compose (for Docker deployment)
  • -
  • โ€ข Bun 1.2.9+ (for native deployment)
  • -
  • โ€ข Proxmox VE or LXD (for LXC container deployment)
  • -
-
-
-
-
-
- -
- - -
-

Installation Options

-

Choose the installation method that works best for your environment.

- - -
-

- ๐Ÿณ Using Docker (Recommended for most users) -

- -
-

Docker provides the easiest way to get started with minimal configuration.

- -
- {[ - { step: 'Clone the repository', cmd: 'git clone https://github.com/RayLabsHQ/gitea-mirror.git\ncd gitea-mirror' }, - { step: 'Start the application in production mode', cmd: 'docker compose up -d' }, - { step: 'Access the application', cmd: null, text: 'Open your browser and navigate to http://localhost:4321' } - ].map((item, i) => ( -
-
- STEP {i + 1} - {item.step} -
- {item.cmd ? ( -
-
{item.cmd}
-
- ) : ( -

- )} -
- ))} -
-
-
- - -
-

- ๐Ÿƒ Using Bun (Native Installation) -

- -
-

If you prefer to run the application directly on your system:

- -
-
-
- STEP 1 - Clone the repository -
-
-
git clone https://github.com/RayLabsHQ/gitea-mirror.git
-cd gitea-mirror
-
-
- -
-
- STEP 2 - Run the quick setup script -
-
-
bun run setup
-
-

This installs dependencies and initializes the database.

-
- -
-
- STEP 3 - Choose how to run the application -
- -
-
-
Development Mode
-
-
bun run dev
-
-

For Bun-specific features, use: bunx --bun astro dev

-
- -
-
Production Mode
-
-
bun run build
-bun run start
-
-
-
-
- -
-
- STEP 4 - Access the application -
-

Open your browser and navigate to http://localhost:4321

-
-
-
-
- - -
-

- ๐Ÿ“ฆ Using LXC Containers (Recommended for Proxmox VE) -

- -
-
-

- Proxmox VE Installation - (Community Script) -

- -

Deploy Gitea Mirror on Proxmox VE using the community-maintained script:

- -
-
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/gitea-mirror.sh)"
-
- -
-

This script will:

-
    -
  • โ€ข Create a privileged Alpine Linux LXC container
  • -
  • โ€ข Install Bun runtime and dependencies
  • -
  • โ€ข Clone and build Gitea Mirror
  • -
  • โ€ข Configure systemd service for automatic startup
  • -
  • โ€ข Set up the application to run on port 4321
  • -
-
- -
-
-
- - - -
-
-

Note

-

After installation, access Gitea Mirror at http://<container-ip>:4321

-
-
-
-
- -
-

- For more information about the community script, visit the - Community Scripts documentation. -

-
-
-
-
- -
- - -
-

Initial Configuration

-

Follow these steps to configure Gitea Mirror for first use:

- -
- {[ - { - num: '1', - title: 'Create Admin Account', - items: [ - "You'll be prompted on first access", - 'Enter your email address and password', - 'This will be your administrator account' - ] - }, - { - num: '2', - title: 'Configure GitHub Connection', - items: [ - 'Navigate to the Configuration page', - 'Enter your GitHub credentials', - 'Select repositories to mirror', - 'Configure filtering options' - ] - }, - { - num: '3', - title: 'Configure Gitea Connection', - items: [ - 'Enter your Gitea server URL', - 'Enter your Gitea access token', - 'Configure organization settings', - 'Set default visibility' - ] - }, - { - num: '4', - title: 'Set Up Scheduling', - items: [ - 'Enable automatic mirroring', - 'Set the mirroring interval', - 'Save your configuration' - ] - } - ].map(step => ( -
-
-
{step.num}
-
-

{step.title}

-
    - {step.items.map(item => ( -
  • โ€ข {item}
  • - ))} -
-
-
-
- ))} -
-
- -
- - -
-

Performing Your First Mirror

- -
-

After completing the configuration, you can start mirroring repositories:

- -
    - {[ - 'Click "Import GitHub Data" to fetch repositories from GitHub', - 'Go to the Repositories page to view your imported repositories', - 'Select the repositories you want to mirror', - 'Click "Mirror Selected" to start the mirroring process', - 'Monitor the progress on the Activity page', - "You'll receive toast notifications about the success or failure of operations" - ].map((step, i) => ( -
  1. - {i + 1} - -
  2. - ))} -
-
-
- -
- - -
-

Troubleshooting

- -
-
-
- - - -
-
-

If you encounter any issues:

- -
-
- โ€ข - Check the Activity Log for detailed error messages -
-
- โ€ข - Verify your GitHub and Gitea tokens have the correct permissions -
-
- โ€ข - Ensure your Gitea instance is accessible from the machine running Gitea Mirror -
-
- -
-
Check logs based on your deployment method:
- -
-
-
- Docker: - docker logs gitea-mirror -
-
- Native: - Check terminal output or system logs -
-
- LXC: - systemctl status gitea-mirror - or - journalctl -u gitea-mirror -f -
-
-
- -
-
- โ€ข - Use the health check endpoint: curl http://your-server:4321/api/health -
-
- โ€ข - For database issues: bun run check-db or bun run fix-db -
-
-
-
-
-
-
- -
- - -
-

Next Steps

- -
-

After your initial setup:

- -
-
- {[ - 'Explore the dashboard for an overview of your mirroring status', - 'Set up automatic mirroring schedules for hands-off operation', - 'Configure organization mirroring for team repositories', - 'Use the cleanup button in Activity Log to manage old events' - ].map(item => ( -
- โœ“ - {item} -
- ))} -
- -
-
- ๐Ÿ“– - Check out the Configuration Guide for advanced settings -
-
- ๐Ÿ—๏ธ - Review the Architecture Documentation to understand the system -
-
- ๐Ÿ“Š - For server deployments, set up monitoring using the health check endpoint -
-
-
-
-
-
-
-
diff --git a/www/src/components/Header.tsx b/www/src/components/Header.tsx index 2eabc4b..b559314 100644 --- a/www/src/components/Header.tsx +++ b/www/src/components/Header.tsx @@ -18,7 +18,8 @@ export function Header() { { href: '/#features', label: 'Features' }, { href: '/#use-cases', label: 'Use Cases' }, { href: '/#screenshots', label: 'Screenshots' }, - { href: '/#installation', label: 'Installation' } + { href: '/#installation', label: 'Installation' }, + { href: '/docs/', label: 'Docs' } ]; return ( diff --git a/www/src/layouts/DocsLayout.astro b/www/src/layouts/DocsLayout.astro new file mode 100644 index 0000000..d288708 --- /dev/null +++ b/www/src/layouts/DocsLayout.astro @@ -0,0 +1,281 @@ +--- +import '../styles/global.css'; +import { Header } from '../components/Header'; +import Footer from '../components/Footer.astro'; +import { docsNav } from '../lib/docs-nav'; + +const { frontmatter, headings = [] } = Astro.props; +const title = frontmatter?.title ?? 'Documentation'; +const description = + frontmatter?.description ?? + 'Documentation for Gitea Mirror, the self-hosted GitHub to Gitea mirroring service.'; + +const currentPath = Astro.url.pathname.endsWith('/') + ? Astro.url.pathname + : `${Astro.url.pathname}/`; +const canonical = `https://gitea-mirror.raylabs.io${currentPath}`; +const toc = headings.filter((h: { depth: number }) => h.depth === 2 || h.depth === 3); +--- + + + + + + {title} ยท Gitea Mirror Docs + + + + + + + + + + + + +
+
+
+ + + + +
+ +
+ + Docs navigation + +
+ {docsNav.map((section) => ( +
+
+ {section.title} +
+ +
+ ))} +
+
+ +
+ +
+
+ + + {toc.length > 1 && ( + + )} +
+
+