services:
  gitea:
    image: docker.gitea.com/gitea:1.25.3-rootless
    container_name: gitea
    environment:
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=gitea-db:5432
      - GITEA__database__NAME=${GITEA_DB:?}
      - GITEA__database__USER=${GITEA_DB_USER:?}
      - GITEA__database__PASSWD=${GITEA_DB_PASSWORD:?}
    restart: always
    volumes:
      - ./data:/var/lib/gitea
      - ./config:/etc/gitea
      - /etc/localtime:/etc/localtime:ro
    #ports:
    #  - ${GITEA_HTTP_PORT:?}:3000
    #  - ${GITEA_SSH_PORT:?}:2222
    depends_on:
      - gitea-db
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 512M
        reservations:
          memory: 256M
    networks:
      - gitea_network

  gitea-db:
    image: docker.io/library/postgres:14
    container_name: gitea-db
    restart: always
    environment:
      - POSTGRES_USER=${GITEA_DB_USER:?}
      - POSTGRES_PASSWORD=${GITEA_DB_PASSWORD:?}
      - POSTGRES_DB=${GITEA_DB:?}
    volumes:
      - ./db:/var/lib/postgresql/data
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 512M
        reservations:
          memory: 256M
    networks:
      - gitea_network

networks:
  gitea_network:
    name: gitea_network
    driver: bridge
