name: gitea

services:
  gitea:
    image: ${GITEA_IMAGE:?Set GITEA_IMAGE}
    container_name: gitea
    environment:
      USER_UID: ${GITEA_UID:-1000}
      USER_GID: ${GITEA_GID:-1000}
      TZ: UTC
      GITEA__database__DB_TYPE: sqlite3
      GITEA__database__PATH: /data/gitea/gitea.db
      GITEA__repository__ROOT: /data/git/repositories
      GITEA__security__INSTALL_LOCK: "true"
      GITEA__security__REVERSE_PROXY_TRUSTED_PROXIES: ${GITEA_PROXY_CIDR:-172.28.0.1/32}
      GITEA__security__ENABLE_REVERSE_PROXY_AUTHENTICATION: "false"
      GITEA__server__DOMAIN: ${GIT_DOMAIN:?Set GIT_DOMAIN}
      GITEA__server__ROOT_URL: https://${GIT_DOMAIN:?Set GIT_DOMAIN}/
      GITEA__server__HTTP_ADDR: 0.0.0.0
      GITEA__server__HTTP_PORT: "3000"
      GITEA__server__DISABLE_SSH: "true"
      GITEA__service__DISABLE_REGISTRATION: "true"
      GITEA__service__REQUIRE_SIGNIN_VIEW: "false"
      GITEA__migrations__ALLOW_LOCALNETWORKS: "false"
      GITEA__migrations__ALLOWED_DOMAINS: github.com,*.github.com
    networks:
      gitea:
        ipv4_address: 172.28.0.2
    ports:
      - "127.0.0.1:3000:3000"
    volumes:
      - ./data:/data
    restart: unless-stopped
    mem_limit: 512m
    mem_reservation: 256m
    cpus: 2.0
    pids_limit: 256
    healthcheck:
      test: ["CMD-SHELL", "wget -q -O - http://127.0.0.1:3000/api/healthz | grep -q 'pass'"]
      interval: 10s
      timeout: 5s
      retries: 18
      start_period: 60s
    logging:
      driver: json-file
      options:
        max-size: 20m
        max-file: "3"

networks:
  gitea:
    ipam:
      config:
        - subnet: 172.28.0.0/24
          gateway: 172.28.0.1
