networks:
  gitea:
    external: false

services:
  server:
    image: docker.gitea.com/gitea:1.25.3
    container_name: gitea
    environment:
      - USER_UID=1001
      - USER_GID=1001
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=db:5432
      - GITEA__database__NAME=${DB_NAME}
      - GITEA__database__USER=${DB_USER}
      - GITEA__database__PASSWD=${DB_PASSWORD}
      - GITEA__server__DOMAIN=git.alogins.net
      - GITEA__server__SSH_DOMAIN=git.alogins.net
      - GITEA__server__ROOT_URL=https://git.alogins.net/
    restart: always
    networks:
      - gitea
    volumes:
      - ${SSH_KEY_PATH}:/data/git/.ssh
      - ${GITEA_DATA}:/data
      - ${BACKUP_DIR}:/backup
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "222:22"
    depends_on:
      - db

  db:
    image: docker.io/library/postgres:14
    restart: always
    environment:
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=${DB_NAME}
    networks:
      - gitea
    volumes:
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
