version: "3"

networks:
  gitea_network:
    external: false
  traefik_traefik-network:
    external: true

services:
  server:
    image: gitea/gitea:latest
    container_name: gitea
    depends_on:
      - database
    environment:
      - USER_UID=[[USER_ID]]
      - USER_GID=[[USER_ID]]
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=database:5432
      - GITEA__database__NAME=[[DATABASE_NAME]]
      - GITEA__database__USER=[[DATABASE_USER]]
      - GITEA__database__PASSWD=[[DATABASE_PASSWD]]
    restart: always
    networks:
      - gitea_network
      - traefik_traefik-network
    volumes:
      - /pwspool/software/gitea/gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    labels:
      - traefik.http.routers.gitea.rule=Host(`[[SITE_URL]]`)
      - traefik.http.routers.gitea.tls=true
      - traefik.http.routers.gitea.tls.certresolver=lets-encrypt
      - traefik.http.services.gitea.loadbalancer.server.port=3000
      - traefik.port=3000

  database:
    image: postgres:14
    restart: always
    networks:
      - gitea_network
    environment:
      - POSTGRES_USER=[[DATABASE_USER]]
      - POSTGRES_PASSWORD=[[DATABASE_PASSWD]]
      - POSTGRES_DB=[[DATABASE_NAME]]
    volumes:
      - /pwspool/software/gitea/database:/var/lib/postgresql/data

