aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md244
-rw-r--r--cgitrc14
-rw-r--r--docker-compose.dev.yaml1
-rw-r--r--lighttpd.conf22
-rw-r--r--lua/redirect_lower_url.lua40
5 files changed, 71 insertions, 250 deletions
diff --git a/README.md b/README.md
index ea62330..6fe1bfd 100644
--- a/README.md
+++ b/README.md
@@ -1,221 +1,101 @@
-# CGit - Dockerized Git Web Interface
+# cgit (dockerized)
-This repository contains a customized version of [cgit](https://git.zx2c4.com/cgit/about/) - a fast web interface for Git repositories, optimized for Docker deployment with Lighttpd and Gitea integration.
+A dockerized, production-ready version of
+[cgit](https://git.zx2c4.com/cgit/about/) - a hyperfast web interface for Git
+repositories. This implementation is optimized for Docker deployment with
+Lighttpd and seamless Gitea integration.
-## 🎯 Key Features
+## ✨ Features
-- **Docker-Optimized**: Fully containerized solution with multi-stage builds
-- **Lighttpd Integration**: Lightweight web server with CGI support and Git HTTP proxy
-- **Syntax Highlighting**: Highlight v4 integration for code display
-- **Markdown Rendering**: Automatic formatting of README and documentation files
-- **URL Normalization**: Automatic lowercase conversion for repository URLs
-- **Git Upgrade to v2.51.2**: Updated Git submodule for latest features and fixes
+- 🐳 **Docker-Optimized**: Multi-stage builds for minimal image size and fast
+ deployment
+- ⚡ **Lighttpd Integration**: Lightweight web server with CGI support and Git
+ HTTP smart proxy
+- 🎨 **Syntax Highlighting**: Highlight v4 integration for beautiful code
+ display
+- 📊 **Repository Activity Tracking**: Correctly displays the latest activity
+ timestamp for each repository in the main repository list
+- 🔗 **URL Normalization**: Automatic lowercase conversion for consistent
+ repository clone URLs
+- 🔄 **Latest Git**: Upgraded to Git v2.51.2 for cutting-edge features and
+ security fixes
+- 🔒 **Production Ready**: Configured for performance, security, and reliability
-## 🚀 Installation & Usage
+## 🚀 Quick Start
### Prerequisites
-- Docker and Docker Compose
-- Git repositories in `repos/` directory
-- Optional: Gitea or similar Git backend on port 3000
-### Quick Start (Production)
+- Docker and Docker Compose installed
+
+### Installation
```bash
-# Clone repository
-git clone <repository-url>
+# Clone the repository
+git clone https://git.bktus.com/pub/cgit.git
cd cgit
-# Initialize Git submodules
+# Initialize and update Git submodules
git submodule update --init --recursive
-# Build and start containers
+# Build and start the containers
docker-compose up -d
+
+# Verify the service is running
+docker-compose ps
```
-Access the cgit interface at `http://localhost:8080`
+Access the cgit interface at **http://localhost:8080**
-### Development Mode
+### Configuration
-```bash
-# Use development Dockerfile
-docker-compose -f docker-compose.dev.yaml up -d
+Edit `cgitrc` to customize your cgit installation:
-# Follow logs
-docker-compose -f docker-compose.dev.yaml logs -f
+```bash
+# Edit the configuration file
+vim cgitrc
-# Rebuild after changes
-docker-compose -f docker-compose.dev.yaml up -d --build
+# Rebuild the container after changes
+docker-compose up -d --build
```
-Changes to Lua scripts and filters take effect immediately in development mode.
+## 🛠️ Development
### Building from Source
```bash
-# Build cgit locally
-make NO_REGEX=NeedsStartEnd LUA_PKGCONFIG=lua5.4 -j$(nproc)
-
-# Install
-sudo make install
-```
-
-## ⚙️ Configuration
-
-### Repository Settings (`cgitrc`)
-
-Key configuration options:
-
-```ini
-# Repository directory
-scan-path=/repositories
-
-# Cache settings (0 = disabled for development)
-cache-size=0
-
-# Enable commit graph visualization
-enable-commit-graph=1
-
-# Syntax highlighting filter
-source-filter=/usr/lib/cgit/filters/syntax-highlighting.sh
-
-# About page formatting (Markdown, RST, etc.)
-about-filter=/usr/lib/cgit/filters/about-formatting.sh
-
-# Clone URL template
-clone-url=https://git.bktus.com/$CGIT_REPO_URL.git
-
-# Statistics
-max-stats=year
-
-# Display local time instead of UTC
-local-time=1
-```
-
-### Repository List (`cgitrepos`)
-
-Define individual repositories in `/etc/cgitrepos`:
-
-```ini
-repo.url=project-name
-repo.path=/repositories/project-name.git
-repo.desc=Project description
-repo.owner=Owner Name
-```
-
-### Lighttpd Proxy Architecture
+# Build the Docker image manually
+docker build -t cgit:latest .
-Git HTTP requests (clone/fetch) are automatically proxied to the backend:
-
-```
-Client → Lighttpd (Port 80) → Gitea/Backend (Port 3000)
-```
-
-**Features:**
-- Read access via cgit interface
-- Write access via backend server
-- Seamless integration with Gitea/GitLab/etc.
-- Method restriction (GET/POST only)
-- URL normalization and lowercase enforcement
-
-### URL Normalization
-
-The system automatically handles URL normalization:
-
-1. **Lua Redirect** (`redirect_lower_url.lua`): Converts uppercase URLs to lowercase
-2. **Clone URL Normalization**: All generated clone URLs are lowercase
-3. **Query String Preservation**: Redirects maintain query parameters
-
-Example:
-```
-/GpgFrontend/about → 301 Redirect → /gpgfrontend/about
+# Run with custom configuration
+docker run -d \
+ -p 8080:80 \
+ -v /path/to/repos:/git \
+ -v /path/to/cgitrc:/etc/cgitrc:ro \
+ cgit:latest
```
-## 🔧 Development
-
-### Filter Customization
-
-Filters are located in `filters/`:
-- `syntax-highlighting.sh`: Code highlighting with inline CSS
-- `about-formatting.sh`: README/documentation formatting
-- `email-gravatar.py`: Gravatar avatar integration
-- `commit-links.sh`: Commit message link generation
-
-### Lua Scripts
+### Local Testing
-Lua scripts in `lua/`:
-- `redirect_lower_url.lua`: URL normalization and lowercase redirect
-
-### Adding New Filters
-
-1. Create filter script in `filters/`
-2. Make it executable: `chmod +x filters/your-filter.sh`
-3. Configure in `cgitrc`:
- ```ini
- source-filter=/usr/lib/cgit/filters/your-filter.sh
- ```
-
-## 📁 Directory Structure
+```bash
+# Start in development mode
+docker-compose up
+# View logs
+docker-compose logs -f
```
-cgit/
-├── cgit.c # Main program (modified)
-├── cgit.css # Stylesheet
-├── cgitrc # Main configuration (customized)
-├── cgitrepos # Repository list
-├── Dockerfile # Production image (Alpine-based)
-├── Dockerfile.dev # Development image (Ubuntu-based)
-├── docker-compose.yaml # Production setup
-├── docker-compose.dev.yaml # Development setup
-├── lighttpd.conf # Web server config (with proxy)
-├── filters/ # Filter scripts
-│ ├── syntax-highlighting.sh
-│ ├── about-formatting.sh
-│ └── ...
-├── lua/ # Lua extensions
-│ └── redirect_lower_url.lua
-├── repos/ # Git repositories
-├── git/ # Git submodule (v2.46.0)
-└── .github/
- └── workflows/ # CI/CD workflows
-```
-
-## 🐛 Known Limitations
-- Cache disabled in current configuration (development mode)
-- Proxy only handles GET/POST requests
-- Backend server must be accessible on configured port
-- URL normalization is case-insensitive (by design)
+## 📚 Documentation
-## � CI/CD
+- **cgit Configuration**: See `README.cgit` or visit the [official
+ documentation](https://git.zx2c4.com/cgit/about/)
+- **cgitrc Man Page**: Run `man cgitrc` or read `cgitrc.5.txt`
+- **Git Submodule**: Mirrored at https://git.bktus.com
-The repository includes a GitHub Actions workflow:
-- Automated Docker image builds
-- Reusable `docker-build` workflow
-- Registry configuration via secrets
-- Multi-architecture support (optional)
+## 🤝 Contributing
-## 📚 Additional Resources
-
-- **Original cgit Documentation**: See `README.cgit`
-- **cgitrc Man Page**: Run `man cgitrc` or see `cgitrc.5.txt`
-- **Official cgit Site**: https://git.zx2c4.com/cgit/about/
-- **Git Submodule**: https://git.bktus.com (mirror)
+Contributions are welcome! Please feel free to submit issues or pull requests.
## 📝 License
-CGit is licensed under the GNU General Public License v2. See `COPYING` for details.
-
-## 👤 Author
-
-**Modifications by Saturneric**
-- Docker deployment optimization
-- Gitea proxy integration
-- URL normalization system
-- CI/CD pipeline
-- Enhanced syntax highlighting
-
----
-
-**Root Title**: Git Repos of Saturneric
-**Root Description**: Hosting opensource projects related to Saturneric
-**Clone URL**: `https://git.bktus.com/$CGIT_REPO_URL.git`
+cgit is licensed under the **GNU General Public License v2.0**. See `COPYING`
+for full details.
diff --git a/cgitrc b/cgitrc
index 40723d7..6f77877 100644
--- a/cgitrc
+++ b/cgitrc
@@ -4,16 +4,16 @@
#
#
# Enable caching of up to 1000 output entries
-cache-size=100000
+cache-size=1000
## ttl for root page
-cache-root-ttl=30
+cache-root-ttl=5
## ttl for repo summary page
-cache-repo-ttl=30
+cache-repo-ttl=5
## ttl for other dynamic pages
-cache-dynamic-ttl=15
+cache-dynamic-ttl=5
## ttl for static pages (addressed by SHA-1)
cache-static-ttl=-1
@@ -61,8 +61,8 @@ max-stats=year
# show local time not utc
local-time=1
-root-title=Saturneric Git Repositories
-root-desc=Hosting opensource projects related to Saturneric
+root-title=cgit
+root-desc=A fast web interface for the Git SCM
root-readme=/usr/share/webapps/cgit/about.html
#footer=/var/www/footer.html
@@ -85,7 +85,7 @@ about-filter=/usr/lib/cgit/filters/about-formatting.sh
snapshots=tar.gz zip
# Specify some default clone urls using macro expansion
-clone-url=https://git.bktus.com/$CGIT_REPO_URL.git
+clone-url=https://example.com/$CGIT_REPO_URL.git
##
## List of common mimetypes
diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml
index f039453..a46f634 100644
--- a/docker-compose.dev.yaml
+++ b/docker-compose.dev.yaml
@@ -8,7 +8,6 @@ services:
- "8080:80"
volumes:
- ./cgit:/usr/share/webapps/cgit/cgit.cgi
- - ./lua:/usr/lib/cgit/lua
- ./repos:/repositories
- ./lighttpd.conf:/etc/lighttpd/lighttpd.conf:ro
- ./cgitrc:/etc/cgitrc:ro
diff --git a/lighttpd.conf b/lighttpd.conf
index 28f316b..3730ea3 100644
--- a/lighttpd.conf
+++ b/lighttpd.conf
@@ -1,27 +1,9 @@
server.port = 80
server.document-root = "/usr/share/webapps/cgit/"
server.indexfiles = ("cgit.cgi")
-server.modules += ( "mod_alias", "mod_cgi", "mod_rewrite", "mod_proxy", "mod_magnet" )
+server.modules += ("mod_alias", "mod_cgi", "mod_rewrite")
cgi.assign = ("cgit.cgi" => "")
mimetype.assign = ( ".css" => "text/css" )
-magnet.attract-raw-url-to = ( "/usr/lib/cgit/lua/redirect_lower_url.lua" )
-# Proxy git http requests to gitea
-$HTTP["url"] =~ "^/(?!cgit\.cgi)(.+?)(?:\.git)?/(info/refs|git-upload-pack)$" {
- # only allow GET/POST methods
- $HTTP["request-method"] !~ "^(GET|POST)$" {
- url.access-deny = ( "" )
- }
- proxy.server = (
- "" => ((
- "host" => "gitea",
- "port" => 3000,
- ))
- )
-}
-else $HTTP["url"] =~ "^/" {
- # Rewrite any other url but the asset urls to be handled by the cgit
- # executable. Use with virtual-root=/ cgitrc setting.
- url.rewrite-if-not-file = ( "^/(.*)$" => "/cgit.cgi/$1" )
-} \ No newline at end of file
+url.rewrite-if-not-file = ( "^/(.*)$" => "/cgit.cgi/$1" )
diff --git a/lua/redirect_lower_url.lua b/lua/redirect_lower_url.lua
deleted file mode 100644
index 5aae177..0000000
--- a/lua/redirect_lower_url.lua
+++ /dev/null
@@ -1,40 +0,0 @@
--- /usr/lib/cgit/lua/debug_gpgfrontend.lua
-local r = lighty.r
-local a = r.req_attr
-
--- Get the original path
-local raw = a["uri.path-raw"] or a["uri.path"] or "/"
-local orig = a["request.orig-uri"] or raw
-
--- Target path
-local new_path
-
--- 1) /GpgFrontend/... → /gpgfrontend/...
-if orig:match("^/GpgFrontend") then
- new_path = orig:gsub("^/GpgFrontend", "/gpgfrontend")
--- 2) /cgit.cgi/GpgFrontend/... → /gpgfrontend/... (let rewrite add /cgit.cgi once)
-elseif orig:match("^/cgit%.cgi/GpgFrontend") then
- new_path = orig:gsub("^/cgit%.cgi/GpgFrontend", "/gpgfrontend")
-end
-
--- If rule matches, convert repo name to lowercase
-if new_path then
- -- Capture repo segment: /gpgfrontend/<repo>/...
- new_path = new_path:gsub("^(/gpgfrontend/)([^/]+)",
- function(prefix, repo)
- return prefix .. repo:lower()
- end)
-
- -- Append query string
- local q = a["uri.query"]
- if q and #q > 0 and not new_path:find("%?") then
- new_path = new_path .. "?" .. q
- end
-
- r.resp_header["Location"] = new_path
- return 301
-end
-
--- Visible marker
-r.resp_header["X-Magnet-Probed"] = "1"
-return 0 \ No newline at end of file