Gitea is a self-hosted Git service that provides a web-based interface for managing Git repositories. It’s designed to be lightweight, fast, and easy to use, making it a popular choice for both personal and business use. With Gitea, you can host your own Git repositories, manage user access, and collaborate on code with others.

In this blog post, we’ll guide you through the process of installing Gitea on a Raspberry Pi using Portainer.

Prerequisites Link to heading

  • Raspberry Pi 4 setup and updated
  • Portainer installed
  • Nginx Proxy Manager service installed

Step 0 - Define local mount folder Link to heading

Service will use local folders, mounted to docker container, to store its data.

For service we will need to create folder:

  • /ssd/gitea/db
  • /ssd/gitea/data
mkdir -p /ssd/gitea/db
mkdir -p /ssd/gitea/data

Step 1 - Install Gitea Link to heading

With Portainer installed, it is possible to start Gitea stack. To do this, follow these steps:

  • Open Portainer in your web browser and navigate to the “Stacks” page
  • Click the “Add stack” button
  • Enter a name for the stack (e.g., “gitea”) and paste the following code into the “Web editor” section:
version: "3"

networks:
  gitea-network:
  intranet:
    external: true

services:
  server:
    image: gitea/gitea:1.17
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=db:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=gitea
    restart: always
    networks:
      gitea-network:
      intranet:
        aliases: 
          - gitea
    volumes:
      - /ssd/gitea/data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "222:22"
    depends_on:
      - db

  db:
    image: postgres:14
    restart: always
    environment:
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=gitea
      - POSTGRES_DB=gitea
    networks:
      gitea-network:
    volumes:
      - /ssd/gitea/db:/var/lib/postgresql/data

Step 2 - Configure Gitea Link to heading

Once the Gitea container is running, you can access the web interface by navigating to http://<homelab>:3000.

The first time you access the web interface, you’ll be prompted to create an admin account. After you create an account, you can start using Gitea to host your own Git repositories and collaborate with others.

Step 3 - Configure Proxy Link to heading

Now your stack is accessible on http://<homelab>:8000. Such URLs with port number do not look too friendly. However, there should be Nginx Proxy Manager installed and running already, if followed Homelab. Proxy. It allows to create proxied hosts and assign them nice names:

  • Add new Proxied Host
  • Fill required information
    • Domain names. Assume router is configured to pass domain home to homelab. Then, lets assume gitea be a subdomain git. Then define domain name git.home. It is possible to assing multiple domain names
    • Forward hostname. Both services - gitea and nginx proxy manager are connected to the same network intranet. Thus we can use alias defined to access them. Define gitea
    • Forward port. As defined in stack, gitea should listen on port 3000.

TO BE CONTINUED… Link to heading

And that’s it! You now have your own git server running on your homelab. Now, you can host your own Git repositories, manage user access, and collaborate on code with others.

In the following post Homelab. Seafile, I will describe how to install Seafile - an open-source cloud storage platform that provides file synchronization and collaboration capabilities.