Gitea

A painless, self-hosted Git service forked from Gogs — providing Git hosting, code review, team collaboration, package registry, and CI/CD in a lightweight single-binary deployment. Perfect for individuals and small teams who want full control over their code without GitHub/GitLab overhead.

yaml

docker-compose.yml

services:
  server:
    image: gitea/gitea:1.26
    container_name: gitea
    restart: unless-stopped
    networks:
      - gitea
    volumes:
      - gitea:/data
    ports:
      - "3000:3000"
      - "222:22"
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=db:5432
      - GITEA__database__NAME=${POSTGRES_DB}
      - GITEA__database__USER=${POSTGRES_USER}
      - GITEA__database__PASSWD=${POSTGRES_PASSWORD}
    depends_on:
      db:
        condition: service_healthy
    healthcheck:
      test:
        - CMD
        - curl
        - "-f"
        - http://localhost:3000/
      interval: 30s
      timeout: 10s
      retries: 5
  db:
    image: postgres:16-alpine
    restart: unless-stopped
    networks:
      - gitea
    volumes:
      - postgres:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
    healthcheck:
      test:
        - CMD-SHELL
        - pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}
      interval: 10s
      timeout: 5s
      retries: 5
networks:
  gitea:
    external: false
volumes:
  gitea:
    driver: local
  postgres:
    driver: local

.ENV

.env example

POSTGRES_USER=gitea
POSTGRES_PASSWORD=changeMe123
POSTGRES_DB=gitea
GITEA__server__DOMAIN=gitea.local
GITEA__server__ROOT_URL=http://localhost:3000/

deployment

Quick Start

  1. Create a working directory named after the service.
  2. Copy the compose file and generated `.env` into that directory.
  3. Review the variables and replace placeholders with real values.
  4. Run `docker compose up -d`.
mkdir gitea
cd gitea
# create docker-compose.yml
# create .env
docker compose up -d