Collection of NotesDockerDocker Deploy Gitea
Collection of NotesDockerDocker Deploy Gitea
Docker

Docker Deploy Gitea

1. Docker Compose File

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__database__DB_TYPE=mysql
      - GITEA__database__HOST=db:3306
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=gitea
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "222:22"
    depends_on:
      - db

  db:
    image: mariadb
    container_name: gitea_db
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=gitea
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=gitea
      - MYSQL_DATABASE=gitea
    networks:
      - gitea
    volumes:
      - ./mysql:/var/lib/mysql

2. Modify Gitea Config File

docker compose up -d

After starting up the docker container, go to ./gitea/gitea/gitea/conf.

app.ini includes the config. Refer to Gitea Config Cheat Sheet for parameter details.

I’ve added the following custom config to force new repo as private, disable registration and sign-in to view contents.

[repository]
FORCE_PRIVATE = true

[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = false

[service]
DISABLE_REGISTRATION = true
REQUIRE_SIGNIN_VIEW = true

Restart the container to make the new config effective.

docker compose restart

3. Set Up Gitea Repo

Add public key to Gitea/Settings/SSH and GPG keys/Manage SSH keys/Add key.

Add a repo via Gitea web.

At local host, clone the new empty repo.

git clone http://152.136.225.247:3000/pan/work
Cloning into 'work'...
warning: You appear to have cloned an empty repository.

Add main branch to remote Gitea repo.

git remote add main http://152.136.225.247:3000/pan/work

git remote -v
main    http://152.136.225.247:3000/pan/work (fetch)
main    http://152.136.225.247:3000/pan/work (push)

git push --set-upstream main main

Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 272 bytes | 272.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: . Processing 1 references
remote: Processed 1 references in total
To http://152.136.225.247:3000/pan/work
 * [new branch]      main -> main
branch 'main' set up to track 'main/main'.

Leave a Reply

Your email address will not be published. Required fields are marked *