Gitea Setup

Self-Hosting Jun 9, 2021

When looking to Self-Host a Git server there are two real options. GitLab and Gitea we will be setting up Gitea as this uses around 300MB of RAM compared to GitLab which uses in excess of 4GB! So unless you need all the features that come with GitLab, Gitea is the way to go!

What is Gitea?

"Gitea is a painless self-hosted Git service. It is similar to GitHub, Bitbucket, and GitLab. Gitea is a fork of Gogs." - Gitea

Prerequisites:

Install

  1. Head to your home or docker directory: cd
  2. Create a directory for Gitea: sudo mkdir gitea && cd gitea
  3. Create the docker-compose.yaml file:

Use the following template
sudo nano docker-compose.yaml

version: '2'
services:
  web:
    image: gitea/gitea:latest
    container_name: gitea
    volumes:
      - ./data:/data
    depends_on:
      - db
    restart: always
    networks:
      default:
        ipv4_address: 10.10.10.18
  db:
    image: mariadb:10
    container_name: gitea-db
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=CHANGEME
      - MYSQL_DATABASE=gitea
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=CHANGEME2
    volumes:
      - ./db:/var/lib/mysql
    networks:
      default:
        ipv4_address: 10.10.10.17
      
networks:
  default:
    external:
      name: dockernet

Change:

  • IP's
  • CHANGEME
  • CHANGEME2

Use gitea/gitea:linux-arm64 if you are using an ARM 64 device such as the Raspberry Pi 4.

Create a Docker network if you haven't already:
sudo docker network create --driver=bridge --subnet=10.10.10.0/24 --gateway=10.10.10.1 dockernet

  1. Spin it up: sudo docker-compose up -d
  2. Configure your reverse proxy

Example Caddyfile config:

gitea.example.com {
  reverse_proxy 10.10.10.18:3000
}

Configuration via the WebUI

  1. Select MySQL
  2. Enter the IP of the database. e.g: 10.10.10.17
  3. Enter your MySQL username. e.g: gitea
  4. Enter your password that you changed earlier ;)

The only other essential task is to create your admin account at the bottom.

Now it's time to Git!
Guy Coding, Gif

Comments

Tags