Install Gitea with Docker

less than 1 minute read

docker-compose

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:1.21.10
    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
    volumes:
      - ./gitea:/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
    volumes:
      - ./postgres:/var/lib/postgresql/data

First registered user will be site admin.

Webhook

Create webhook with curl:

curl --location --request POST 'http://192.168.1.62:3000/api/v1/repos/fdbai/try-gitea/hooks' \
	--header 'Content-Type: application/json' \
	--header 'Authorization: token 559df24d1e2120960e3c0514cc2334b2d6a71a1e' \
	--header 'Content-Type: application/json' \
	--data-raw '{
		"active": true,
		"branch_filter": "*",
		"config": {
			"content_type": "json",
			"url": "http://192.168.1.62:3000/fdbai/try-gitea",
			"http_method": "post"
		},
		"events": ["push"],
		"type": "gitea"
}'