diff --git a/src/content/docs/architecture.md b/src/content/docs/architecture.md deleted file mode 100644 index 7b5f8d1..0000000 --- a/src/content/docs/architecture.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -title: "Architecture" -description: "Comprehensive overview of the Gitea Mirror application architecture." -order: 1 -updatedDate: 2025-05-22 ---- - -
-

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.

-
- -The application is built using: - -- Astro: Web framework for the frontend -- React: Component library for interactive UI elements -- Shadcn UI: UI component library built on Tailwind CSS -- SQLite: Database for storing configuration, state, and events -- Bun: Runtime environment for the backend -- Drizzle ORM: Type-safe ORM for database interactions - -## Architecture Diagram - -```mermaid -graph TD - subgraph "Gitea Mirror" - Frontend["Frontend
(Astro + React)"] - Backend["Backend
(Bun)"] - Database["Database
(SQLite + Drizzle)"] - - Frontend <--> Backend - Backend <--> Database - end - - subgraph "External APIs" - GitHub["GitHub API"] - Gitea["Gitea API"] - end - - Backend --> GitHub - Backend --> Gitea -``` - -## 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: - -- **Dashboard**: Overview of mirroring status and recent activity -- **Repository Management**: Interface for managing repositories to mirror -- **Organization Management**: Interface for managing GitHub organizations -- **Configuration**: Settings for GitHub and Gitea connections -- **Activity Log**: Detailed log of mirroring operations - -### Backend (Bun) - -The backend is built with Bun and provides API endpoints for the frontend to interact with. It handles: - -- Authentication and user management -- GitHub API integration -- Gitea API integration -- Mirroring operations -- Database interactions - -### 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 -- GitHub and Gitea configuration -- Repository and organization information -- Mirroring job history and status -- Event notifications and their read status - -## Data Flow - -1. **User Authentication**: Users authenticate through the frontend, which communicates with the backend to validate credentials. -2. **Configuration**: Users configure GitHub and Gitea settings through the UI, which are stored in the SQLite database. -3. **Repository Discovery**: The backend queries the GitHub API to discover repositories based on user configuration. -4. **Mirroring Process**: When triggered, the backend fetches repository data from GitHub and pushes it to Gitea. -5. **Status Tracking**: All operations are logged in the database and displayed in the Activity Log. - -## 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: - -1. **Docker**: Run as a containerized application using Docker and docker-compose -2. **LXC Containers**: Deploy in Linux Containers (LXC) on Proxmox VE (using community script by [Tobias/CrazyWolf13](https://github.com/CrazyWolf13)) or local workstations -3. **Native**: Run directly on the host system using Bun runtime - -Each deployment method has its own 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 diff --git a/src/content/docs/configuration.md b/src/content/docs/configuration.md deleted file mode 100644 index 7ad164d..0000000 --- a/src/content/docs/configuration.md +++ /dev/null @@ -1,177 +0,0 @@ ---- -title: "Configuration" -description: "Guide to configuring Gitea Mirror for your environment." -order: 2 -updatedDate: 2025-05-22 ---- - -
-

Gitea Mirror Configuration Guide

-

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

-
- -## Configuration Methods - -Gitea Mirror can be configured using: - -1. Environment Variables: Set configuration options through environment variables -2. Web UI: Configure the application through the web interface after installation - -## Environment Variables - -The following environment variables can be used to configure Gitea Mirror: - -| Variable | Description | Default Value | Example | -|----------|-------------|---------------|---------| -| `NODE_ENV` | Runtime environment (development, production, test) | `development` | `production` | -| `DATABASE_URL` | SQLite database URL | `file:data/gitea-mirror.db` | `file:path/to/your/database.db` | -| `JWT_SECRET` | Secret key for JWT authentication | Auto-generated secure random string | `your-secure-random-string` | -| `HOST` | Server host | `localhost` | `0.0.0.0` | -| `PORT` | Server port | `4321` | `8080` | - -### Important Security Note - -The application will automatically generate a secure random `JWT_SECRET` on first run if one isn't provided or if the default value is used. 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: - -1. Navigate to `http://your-server:port/` -2. If this is your first time, you'll be guided through creating an admin account -3. Log in with your credentials -4. Go to the Configuration page - -### GitHub Configuration - -The GitHub configuration section allows you to connect to GitHub and specify which repositories to mirror. - -| Option | Description | Default | -|--------|-------------|---------| -| Username | Your GitHub username | - | -| Token | GitHub personal access token | - | -| Skip Forks | Skip forked repositories | `false` | -| Private Repositories | Include private repositories | `false` | -| Mirror Issues | Mirror issues from GitHub to Gitea | `false` | -| Mirror Wiki | Mirror wiki pages from GitHub to Gitea | `false` | -| Mirror Starred | Mirror starred repositories | `false` | -| Mirror Organizations | Mirror organization repositories | `false` | -| Only Mirror Orgs | Only mirror organization repositories | `false` | -| Preserve Org Structure | Maintain organization structure in Gitea | `false` | -| Skip Starred Issues | Skip mirroring issues for starred repositories | `false` | - -#### GitHub Token Permissions - -Your GitHub token needs the following permissions: - -- `repo` - Full control of private repositories -- `read:org` - Read organization membership -- `read:user` - Read user profile data - -To create a GitHub token: - -1. Go to [GitHub Settings > Developer settings > Personal access tokens](https://github.com/settings/tokens) -2. Click "Generate new token" -3. Select the required permissions -4. Copy the generated token and paste it into Gitea Mirror - -### Gitea Configuration - -The Gitea configuration section allows you to connect to your Gitea instance and specify how repositories should be mirrored. - -| Option | Description | Default | -|--------|-------------|---------| -| URL | Gitea server URL | - | -| Token | Gitea access token | - | -| Organization | Default organization for mirrored repositories | - | -| Visibility | Default visibility for mirrored repositories | `public` | -| Starred Repos Org | Organization for starred repositories | `github` | - -#### Gitea Token Creation - -To create a Gitea access token: - -1. Log in to your Gitea instance -2. Go to Settings > Applications -3. Under "Generate New Token", enter a name for your token -4. Click "Generate Token" -5. Copy the generated token and paste it into Gitea Mirror - -### Schedule Configuration - -You can configure automatic mirroring on a schedule: - -| Option | Description | Default | -|--------|-------------|---------| -| Enable Scheduling | Enable automatic mirroring | `false` | -| Interval (seconds) | Time between mirroring operations | `3600` (1 hour) | - -## Advanced Configuration - -### Repository Filtering - -You can include or exclude specific repositories using patterns: - -- Include patterns: Only repositories matching these patterns will be mirrored -- Exclude patterns: Repositories matching these patterns will be skipped - -Example patterns: -- `*` - All repositories -- `org-name/*` - All repositories in a specific organization -- `username/repo-name` - A specific repository - -### Database Management - -Gitea Mirror includes several database management tools that can be run from the command line: - -```bash -# 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. You can manage these events using the following scripts: - -```bash -# View all events in the database -bun scripts/check-events.ts - -# Mark all events as read -bun scripts/mark-events-read.ts -``` - -For cleaning up old activities and events, use the cleanup button in the Activity Log page of the web interface. - -### Health Check Endpoint - -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 - -You can use this endpoint for monitoring your deployment: - -```bash -# 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/content/docs/quickstart.md b/src/content/docs/quickstart.md deleted file mode 100644 index aec4230..0000000 --- a/src/content/docs/quickstart.md +++ /dev/null @@ -1,182 +0,0 @@ ---- -title: "Quick Start Guide" -description: "Get started with Gitea Mirror quickly." -order: 3 -updatedDate: 2025-05-22 ---- - -
-

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 -2. A Gitea instance with an access token -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. - -1. Clone the repository: - ```bash - git clone https://github.com/arunavo4/gitea-mirror.git - cd gitea-mirror - ``` - -2. Start the application in production mode: - ```bash - docker compose up -d - ``` - -3. Access the application at [http://localhost:4321](http://localhost:4321) - -### Using Bun (Native Installation) - -If you prefer to run the application directly on your system: - -1. Clone the repository: - ```bash - git clone https://github.com/arunavo4/gitea-mirror.git - cd gitea-mirror - ``` - -2. Run the quick setup script: - ```bash - bun run setup - ``` - This installs dependencies and initializes the database. - -3. Choose how to run the application: - - **Development Mode:** - ```bash - bun run dev - ``` - - Note: For Bun-specific features, use: - ```bash - bunx --bun astro dev - ``` - - **Production Mode:** - ```bash - bun run build - bun run start - ``` - -4. Access the application at [http://localhost:4321](http://localhost:4321) - -### Using LXC Containers (Recommended for server deployments) - -#### Proxmox VE (Online Installation) - -For deploying on a Proxmox VE host with internet access: - -```bash -# Optional env overrides: CTID HOSTNAME STORAGE DISK_SIZE CORES MEMORY BRIDGE IP_CONF -sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/arunavo4/gitea-mirror/main/scripts/gitea-mirror-lxc-proxmox.sh)" -``` - -This script: -- Creates a privileged LXC container -- Installs Bun and dependencies -- Clones and builds the application -- Sets up a systemd service - -#### Local LXD (Offline-friendly Installation) - -For testing on a local workstation or in environments without internet access: - -1. Clone the repository locally: - ```bash - git clone https://github.com/arunavo4/gitea-mirror.git - ``` - -2. Download the Bun installer once: - ```bash - curl -L -o /tmp/bun-linux-x64.zip https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64.zip - ``` - -3. Run the local LXC installer: - ```bash - sudo LOCAL_REPO_DIR=~/path/to/gitea-mirror ./gitea-mirror/scripts/gitea-mirror-lxc-local.sh - ``` - -For more details on LXC deployment, see the [LXC Container Deployment Guide](https://github.com/arunavo4/gitea-mirror/blob/main/scripts/README-lxc.md). - -## Initial Configuration - -Follow these steps to configure Gitea Mirror for first use: - -1. **Create Admin Account** - - Upon first access, you'll be prompted to create an admin account - - Choose a secure username and password - - This will be your administrator account - -2. **Configure GitHub Connection** - - Navigate to the Configuration page - - Enter your GitHub username - - Enter your GitHub personal access token - - Select which repositories to mirror (all, starred, organizations) - - Configure repository filtering options - -3. **Configure Gitea Connection** - - Enter your Gitea server URL - - Enter your Gitea access token - - Configure organization and visibility settings - -4. **Set Up Scheduling (Optional)** - - Enable automatic mirroring if desired - - Set the mirroring interval (in seconds) - -5. **Save Configuration** - - Click the "Save" button to store your settings - -## Performing Your First Mirror - -After completing the configuration, you can start mirroring repositories: - -1. Click "Import GitHub Data" to fetch repositories from GitHub -2. Go to the Repositories page to view your imported repositories -3. Select the repositories you want to mirror -4. Click "Mirror Selected" to start the mirroring process -5. Monitor the progress on the Activity page -6. You'll receive toast notifications about the success or failure of operations - -## 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 the terminal output or system logs - - LXC: `systemctl status gitea-mirror` or `journalctl -u gitea-mirror -f` -- Use the health check endpoint to verify system status: `curl http://your-server:4321/api/health` -- For database issues, try the database management tools: `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 -- Check out the [Configuration Guide](/configuration) for advanced settings -- Review the [Architecture Documentation](/architecture) to understand the system -- For server deployments, set up monitoring using the health check endpoint -- Use the cleanup button in the Activity Log page to manage old events and activities diff --git a/src/pages/docs/[slug].astro b/src/pages/docs/[slug].astro deleted file mode 100644 index 1c886f0..0000000 --- a/src/pages/docs/[slug].astro +++ /dev/null @@ -1,63 +0,0 @@ ---- -import { getCollection } from 'astro:content'; -import MainLayout from '../../layouts/main.astro'; - -// Enable prerendering for this dynamic route -export const prerender = true; - -// Generate static paths for all documentation pages -export async function getStaticPaths() { - const docs = await getCollection('docs'); - return docs.map(entry => ({ - params: { slug: entry.slug }, - props: { entry }, - })); -} - -// Get the documentation entry from props -const { entry } = Astro.props; -const { Content } = await entry.render(); ---- - - -
- -
-
- -
-
- -
-
diff --git a/src/pages/docs/architecture.astro b/src/pages/docs/architecture.astro new file mode 100644 index 0000000..fda4caf --- /dev/null +++ b/src/pages/docs/architecture.astro @@ -0,0 +1,330 @@ +--- +import MainLayout from '../../layouts/main.astro'; +--- + + +
+ + +
+ +
+
+ + + + 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 the frontend' }, + { name: 'React', desc: 'Component library for interactive UI elements' }, + { name: 'Shadcn UI', desc: 'UI component library built on Tailwind CSS' }, + { name: 'SQLite', desc: 'Database for storing configuration, state, and events' }, + { name: 'Bun', desc: 'Runtime environment for the backend' }, + { name: 'Drizzle ORM', desc: 'Type-safe ORM for database interactions' } + ].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 and user management', + 'GitHub API integration', + 'Gitea API integration', + 'Mirroring operations', + 'Database interactions' + ].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', + 'GitHub and Gitea configuration', + 'Repository and organization information', + 'Mirroring job history and status', + 'Event notifications and their read status' + ].map(item => ( +
+ + {item} +
+ ))} +
+
+
+
+ +
+ + +
+

Data Flow

+ +
+
    + {[ + { title: 'User Authentication', desc: 'Users authenticate through the frontend, which communicates with the backend to validate credentials.' }, + { 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 or local workstations' }, + { 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 includes a community script by Tobias/CrazyWolf13

+
+
+
+
+
\ No newline at end of file diff --git a/src/pages/docs/configuration.astro b/src/pages/docs/configuration.astro new file mode 100644 index 0000000..ae35fbf --- /dev/null +++ b/src/pages/docs/configuration.astro @@ -0,0 +1,423 @@ +--- +import MainLayout from '../../layouts/main.astro'; + +const envVars = [ + { name: 'NODE_ENV', desc: 'Runtime environment', default: 'development', example: 'production' }, + { 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', default: '-' }, + { name: 'Skip Forks', desc: 'Skip forked repositories', default: 'false' }, + { name: 'Private Repositories', desc: 'Include private repositories', 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 Starred', desc: 'Mirror starred repositories', default: 'false' }, + { name: 'Mirror Organizations', desc: 'Mirror organization repositories', default: 'false' }, + { name: 'Only Mirror Orgs', desc: 'Only mirror organization repositories', default: 'false' }, + { name: 'Preserve Org Structure', desc: 'Maintain organization structure in Gitea', default: 'false' }, + { name: 'Skip Starred Issues', desc: 'Skip mirroring 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 Configuration

+

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

+

Your GitHub token needs the following permissions:

+
    +
  • + + repo - Full control of private repositories +
  • +
  • + + read:org - Read organization membership +
  • +
  • + + read:user - Read user profile data +
  • +
+
+
+
+ +
+
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 Configuration

+

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}
+
+ +
+
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

+ + +
+

Repository Filtering

+ +
+

You can include or exclude specific repositories using patterns:

+ +
+
+

Include Patterns

+

Only repositories matching these patterns will be mirrored

+
+ +
+

Exclude Patterns

+

Repositories matching these patterns will be skipped

+
+
+ +
+
Example Patterns
+
    +
  • * - All repositories
  • +
  • org-name/* - All repositories in a specific organization
  • +
  • username/repo-name - A specific repository
  • +
+
+
+
+ + +
+

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. You can manage these events using the following scripts:

+ +
+
{`# View all events in the database
+bun scripts/check-events.ts
+
+# Mark all events as read
+bun scripts/mark-events-read.ts`}
+
+ +
+
+
+ + + +
+
+

For cleaning up old activities and events, use the cleanup button in the Activity Log page of the web interface.

+
+
+
+
+ + +
+

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`}
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/src/pages/docs/index.astro b/src/pages/docs/index.astro index 3777cb2..8dbf4a9 100644 --- a/src/pages/docs/index.astro +++ b/src/pages/docs/index.astro @@ -1,18 +1,37 @@ --- -import { getCollection } from 'astro:content'; import MainLayout from '../../layouts/main.astro'; import { LuSettings, LuRocket, LuBookOpen } from 'react-icons/lu'; -// Helper to pick an icon based on doc.slug -// We'll use inline conditional rendering instead of this function +// Define our documentation pages directly +const docs = [ + { + slug: 'architecture', + title: 'Architecture', + description: 'Comprehensive overview of the Gitea Mirror application architecture.', + order: 1, + icon: LuBookOpen, + href: '/docs/architecture' + }, + { + slug: 'configuration', + title: 'Configuration', + description: 'Guide to configuring Gitea Mirror for your environment.', + order: 2, + icon: LuSettings, + href: '/docs/configuration' + }, + { + slug: 'quickstart', + title: 'Quick Start Guide', + description: 'Get started with Gitea Mirror quickly.', + order: 3, + icon: LuRocket, + href: '/docs/quickstart' + } +]; -// Get all documentation entries, sorted by order -const docs = await getCollection('docs'); -const sortedDocs = docs.sort((a, b) => { - const orderA = a.data.order || 999; - const orderB = b.data.order || 999; - return orderA - orderB; -}); +// Sort by order +const sortedDocs = docs.sort((a, b) => a.order - b.order); --- @@ -21,24 +40,25 @@ const sortedDocs = docs.sort((a, b) => {

Browse guides and technical docs for Gitea Mirror.

- {sortedDocs.map(doc => ( - - - + \ No newline at end of file diff --git a/src/pages/docs/quickstart.astro b/src/pages/docs/quickstart.astro new file mode 100644 index 0000000..1122195 --- /dev/null +++ b/src/pages/docs/quickstart.astro @@ -0,0 +1,456 @@ +--- +import MainLayout from '../../layouts/main.astro'; +--- + + +
+ + +
+ +
+
+ + + + 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/arunavo4/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/arunavo4/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 server deployments) +

+ +
+
+
+

+ Proxmox VE + (Online Installation) +

+ +

For deploying on a Proxmox VE host with internet access:

+ +
+
# Optional env overrides: 
+# CTID HOSTNAME STORAGE DISK_SIZE 
+# CORES MEMORY BRIDGE IP_CONF
+sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/arunavo4/gitea-mirror/main/scripts/gitea-mirror-lxc-proxmox.sh)"
+
+ +
+

This script:

+
    +
  • Creates a privileged LXC container
  • +
  • Installs Bun and dependencies
  • +
  • Clones and builds the application
  • +
  • Sets up a systemd service
  • +
+
+
+ +
+

+ Local LXD + (Offline-friendly) +

+ +

For testing or environments without internet access:

+ +
    +
  1. + 1. Clone the repository locally: +
    +
    git clone https://github.com/arunavo4/gitea-mirror.git
    +
    +
  2. +
  3. + 2. Download Bun installer: +
    +
    curl -L -o /tmp/bun-linux-x64.zip \
    +  https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64.zip
    +
    +
  4. +
  5. + 3. Run local LXC installer: +
    +
    sudo LOCAL_REPO_DIR=~/path/to/gitea-mirror \
    +  ./gitea-mirror/scripts/gitea-mirror-lxc-local.sh
    +
    +
  6. +
+
+
+ +
+

For more details, see the LXC Container Deployment Guide.

+
+
+
+
+ +
+ + +
+

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", + 'Choose a secure username 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 +
+
+
+
+
+
+
+
\ No newline at end of file