Local Git Server

A self-hosted Git server powered by Gitea with a GitHub-style web interface, repository browsing, issues, pull requests, actions, releases, and SSH/HTTP Git access.

Start it

  1. Copy .env.example to .env.
  2. Change POSTGRES_PASSWORD in .env to a long random value.
  3. Start the stack:
docker compose up -d
  1. Open http://localhost:3000.
  2. Create the first account. The first account becomes an administrator.

The init-permissions service runs once at startup to prepare the docker/ data directories for Gitea and PostgreSQL. It will also correct ownership after restoring data from a backup.

Migrate Existing Data

If you updated from the previous setup that used Docker named volumes, migrate your existing repositories and database before starting the updated stack:

sh ./migrate-to-bind-mounts.sh
docker compose up -d

This works on Linux, TrueNAS, and macOS because it uses POSIX shell and Docker. The script discovers the old Gitea and PostgreSQL volumes from their Docker Compose labels, stops the stack, then copies them into docker/gitea and docker/postgres. It refuses to overwrite non-empty destination directories. On Windows, run it from WSL or Git Bash.

If multiple old stacks exist on the same Docker host, identify the correct volume names with docker volume ls, then set LEGACY_GITEA_VOLUME and LEGACY_POSTGRES_VOLUME before running the migration:

LEGACY_GITEA_VOLUME=your-project_gitea_data
LEGACY_POSTGRES_VOLUME=your-project_postgres_data

The Git SSH endpoint is available on port 2222:

git clone ssh://git@localhost:2222/your-user/your-repository.git

HTTPS cloning is also available from the repository page:

git clone http://localhost:3000/your-user/your-repository.git

Useful commands

# View service logs
docker compose logs -f gitea

# Stop containers but keep repositories and database data
docker compose down

# Stop containers and permanently delete all Git data
docker compose down
Remove-Item -Recurse -Force .\docker

Production notes

  • Put Gitea behind HTTPS with a reverse proxy before exposing it to the internet.
  • Use a managed or separately backed-up PostgreSQL instance for important repositories.
  • Set DISABLE_REGISTRATION=true and REQUIRE_SIGNIN_VIEW=true for a private team server.
  • All persistent data, including repositories, Gitea configuration, attachments, and PostgreSQL data, is stored in docker/. Stop the stack with docker compose down, then back up or move that directory together with .env and docker-compose.yml.
  • Update GITEA_ROOT_URL and GITEA_DOMAIN to the public hostname before deploying.
S
Description
No description provided
Readme
33 KiB
Languages
Shell 100%