version: "3"
services:
  server:
    image: codeberg.org/forgejo/forgejo:v1.21.5-0
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=db:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=gitea
      #- START_SSH_SERVER = true
      #- SSH_PORT = 2222
      #- SSH_DOMAIN = git.ghoscht.com
      #- ROOT_URL=https://git.ghoscht.com
    restart: always
    volumes:
      - gitea_data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "2222:22"
    networks:
      traefik_net:
      database_net:
    dns:
      - 1.1.1.1
    labels:
      - traefik.enable=true
      - traefik.http.routers.gitea.entrypoints=websecure
      - traefik.http.routers.gitea.rule=Host(`git.local.ghoscht.com`,`git.ghoscht.com`)
      - traefik.http.services.gitea.loadbalancer.server.port=3000
      - traefik.docker.network=traefik-net
      - traefik.http.routers.gitea.tls=true
      - traefik.http.routers.gitea.tls.certresolver=lencrypt
  db:
    image: postgres:15.3-bullseye
    container_name: gitea_db
    restart: always
    volumes:
      - gitea_db:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=gitea
      - POSTGRES_DB=gitea
    networks:
      database_net:
networks:
  traefik_net:
    name: traefik-net
    external: true
  database_net:
volumes:
  gitea_data:
    name: gitea_data
  gitea_db:
    name: gitea_db