aboutsummaryrefslogtreecommitdiff

cgit in Docker (Apache)

A lightweight, production-ready Docker image for cgit, the lightweight web frontend for Git repositories.

  • Base: Alpine Linux with Apache httpd (CGI)
  • cgit built from source with LuaJIT filter support
  • Markdown rendering with Pygments syntax highlighting
  • SEO-ready: ships with robots.txt and sitemap.xml
  • Easy theming: override CSS, logo, and favicon without rebuilding

Features

Feature Details
Runtime Alpine + Apache httpd, cgit as CGI
Filters LuaJIT-based filters (requires luajit runtime)
Rendering README.md etc. rendered via python-markdown + Pygments
SEO robots.txt, sitemap.xml, configurable virtual root
Identity Set container PUID/PGID to match your repo owner
Theming Mount your own cgit.css, logo, favicon over the defaults

Quick start

docker run -d \
  --name cgit \
  -p 8086:80 \
  -v $(pwd)/cgitrc:/etc/cgitrc:ro \
  -v cgit-cache:/opt/cgit/cache \
  -v /path/to/your/git/repos:/srv/git:ro \
  jarlucmat/cgit:latest

Then open http://localhost:8086 and add your repositories to cgitrc (see the sample configuration in this repo).

Using Docker Compose

A ready-made docker-compose.yml is included:

services:
  cgit:
    image: jarlucmat/cgit:latest
    restart: always
    container_name: cgit
    ports:
      - "8086:80"
    environment:
      # Should match the uid/gid that owns your git repositories
      PUID: "1000"
      PGID: "1000"
    volumes:
      - ./cgitrc:/etc/cgitrc:ro
      - cgit-cache:/opt/cgit/cache:rw
      - ./path/to/your/git/repos:/srv/git/:ro

volumes:
  cgit-cache:

Configuration

The main configuration file is cgitrc, mounted read-only at /etc/cgitrc. A minimal example:

root-title=My Git Repositories
virtual-root=/

repo.url=myRepo
repo.path=/srv/git/myRepo.git
repo.desc=Description of my repo
repo.owner=Owner Name
repo.clone-url=https://my-host/myRepo

Full documentation: cgitrc.5.

Theming

To customize the look, mount your static assets over the bundled defaults:

volumes:
  - ./cgit.css:/opt/cgit/app/cgit.css:ro
  - ./cgit.png:/opt/cgit/app/cgit.png:ro
  - ./favicon.ico:/opt/cgit/app/favicon.ico:ro

Building from source

docker build -t cgit:local .

The build compiles cgit from source on Alpine (cgit_build.conf configures the build) and installs the runtime dependencies for the filters.

Project layout

├── Dockerfile          # Multi-stage build: cgit from source + HTTP runtime
├── cgit_build.conf     # Build-time cgit configuration
├── cgitrc              # Sample runtime configuration
├── cgit.css            # Default stylesheet (overridable)
├── docker-compose.yml  # Example compose setup
├── entrypoint.sh       # Container entrypoint (PUID/PGID handling)
├── rootfs/             # Files copied into the runtime image
├── robots.txt          # SEO: search engine instructions
└── sitemap.xml         # SEO: sitemap placeholder

License

GPL-3.0-or-later — see LICENSE for details.

Acknowledgements

Inspired by LuqueDaniel/cgit-docker, which helped with the initial approach to containerizing cgit. This implementation differs significantly and uses Apache httpd with CGI for a self-hosted setup.