Sign inSign up

cw4g/gitolite

By cw4g

Updated 8 months ago

simple image to run a gitolite instance with stagit as webfrontend

Image
Developer tools
0

2.2K

cw4g/gitolite repository overview

Gitolite Docker with Stagit Web Interface

A Docker-based Gitolite server with a static web interface powered by stagit.

Bug reports & feedback: github.com/cw4g/gitolite-feedback

Features

  • Gitolite: Git hosting with SSH access control
  • Stagit: Static HTML git repository viewer with dark theme
  • Syntax highlighting: Code highlighting via highlight.js
  • Auto-regeneration: Web interface updates automatically on push
  • Persistent data: SSH host keys and repositories survive container restarts
  • Default branch main: New repositories use main as default branch

Quick Start

  1. Create a docker-compose.yml:

    services:
      gitolite:
        image: cw4g/gitolite
        ports:
          - "2222:22"
          - "8080:80"
        volumes:
          - ./volume:/home/git
        env_file:
          - .env
    
  2. Create a .env file:

    USERNAME=your_username
    SSH_PUBLIC_KEY="ssh-rsa AAAA... your-key"
    

    Replace your_username with your desired admin username and paste your full SSH public key.

  3. Start the container:

    docker compose up -d
    
  4. Access the services:

    • SSH: ssh://git@localhost:2222
    • Web: http://localhost:8080

Usage

Clone the admin repository
git clone ssh://git@localhost:2222/gitolite-admin
Clone other repositories
git clone ssh://git@localhost:2222/<repo-name>
Add repository description

To set a repository description that appears in the web interface, create a .description file in your repository root:

echo "My awesome project" > .description
git add .description
git commit -m "Add description"
git push

The description will be automatically picked up on the next push.

Architecture

├── Dockerfile              # Alpine-based image with Git, SSH, Gitolite, and Stagit
├── docker-compose.yml      # Service configuration (ports 2222 for SSH, 8080 for web)
├── docker-entrypoint.sh    # Container initialization script
├── stagit-gen.sh           # Stagit page generator script
├── lighttpd.conf           # Web server configuration
├── logo.png                # Git logo for web interface
└── volume/                 # Persistent data (mounted to /home/git)
    ├── host_keys/          # SSH host keys
    ├── repositories/       # Git repositories
    └── .gitolite/          # Gitolite configuration and hooks

How It Works

SSH Host Keys

SSH host keys are persisted in ./volume/host_keys/. On first start, keys are generated and saved. On subsequent starts, existing keys are restored to prevent SSH fingerprint warnings.

Stagit Integration
  • stagit-gen: A script that generates static HTML pages for all repositories
  • Post-receive hook: Automatically regenerates pages after each push
  • Dark theme: Custom CSS with a dark color scheme
  • Description support: Reads .description file from repositories
Web Interface

The web interface is served by lighttpd on port 80 (mapped to 8080). It displays:

  • Repository index with descriptions
  • Commit logs
  • File browser
  • Diffs

Commands

# Build the image
make build

# Start the container
make run

# Build and push to Docker Hub
make push

# Push README to Docker Hub
make push-readme

# Push image and README
make push-all

# View logs
docker-compose logs -f

# Stop the container
docker-compose down

# Manually regenerate stagit pages
docker-compose exec gitolite su git -c 'stagit-gen'

Customization

Custom Logo and Favicon

To use your own logo and favicon, add optional volume mounts to docker-compose.yml:

services:
  gitolite:
    image: cw4g/gitolite
    ports:
      - "2222:22"
      - "8080:80"
    volumes:
      - ./volume:/home/git
      # Optional: custom logo and favicon
      - ./my-logo.png:/var/www/git/logo.png:ro
      - ./my-favicon.png:/var/www/git/favicon.png:ro
    env_file:
      - .env

Recommended size: 32x32 pixels PNG.

Custom CSS

To customize the dark theme, mount your own CSS file:

volumes:
  - ./my-style.css:/var/www/git/style.css:ro

Ports

PortServiceDescription
2222SSHGit SSH access
8080HTTPStagit web interface

License

MIT

Tag summary

Content type

Image

Digest

sha256:5bf1a1c4b

Size

24.8 MB

Last updated

8 months ago

docker pull cw4g/gitolite