services:
  gitea:
    image: docker.gitea.com/gitea:1.24-rootless
    container_name: gitea
    environment:
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=postgres:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=gitea
    security_opt:
      - "label=disable"
    restart: always
    networks:
      - gitea
    volumes:
      - /home/gitea/gitea_data:/data:Z
      - /home/gitea/gitea_etc:/etc/gitea:Z
      - /home/gitea/gitea_custom:/var/lib/gitea/custom:Z
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "2222:2222"
    depends_on:
      - postgres
    labels:
      - "io.containers.autoupdate=registry"

  postgres:
    image: docker.io/library/postgres:15
    container_name: postgres
    security_opt:
      - "label=disable"
    restart: always
    environment:
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=gitea
      - POSTGRES_DB=gitea
    networks:
      - gitea
    volumes:
      - /home/gitea/gitea_postgres:/var/lib/postgresql/data:Z
    labels:
      - "io.containers.autoupdate=registry"

networks:
  gitea:
    enable_ipv6: true