services:
  gitea-postgres:
    image: docker.io/library/postgres:15
    environment:
      - POSTGRES_USER=${GITEA_DB_USERNAME}
      - POSTGRES_PASSWORD=${GITEA_DB_PASSWORD}
      - POSTGRES_DB=gitea
    volumes:
      - /docker/management/gitea-postgres/postgres:/var/lib/postgresql/data
    container_name: gitea-postgres
    labels:
      - "komodo.skip=true"
    restart: unless-stopped
    ports:
      - "5433:5432"
    networks:
      - management_internal

  gitea:
    image: gitea/gitea:latest
    container_name: gitea
    ports:
      - "3002:3000"
      - "222:22"
    networks:
      - management_internal
      - gitea_external
    volumes:
      - /docker/management/gitea:/data
      - /docker/management/gitea-postgres:/var/lib/gitea
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - /docker:/docker
      - ./empty:/var/empty
    environment:
      - TZ=America/Edmonton
      - ROOT_URL=${GITEA_ROOT_URL}
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=gitea-postgres:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=${GITEA_DB_USERNAME}
      - GITEA__database__PASSWD=${GITEA_DB_PASSWORD}
    restart: unless-stopped
    depends_on:
      - gitea-postgres

networks:
  management_internal:
    internal: true
  gitea_external:
    external: true