networks:
  dev-net:
    driver: bridge
  ix-databases_shared-databases:
    external: true
  pangolin:
    external: true

services:

  gitea:
    container_name: gitea
    image: gitea/gitea:1.25.3
    restart: unless-stopped
    networks:
      - dev-net
      - ix-databases_shared-databases
      - pangolin
    ports:
      - "3002:3000"
      - "2222:22"
    environment:
      TZ: ${TZ}
      USER_UID: ${PUID}
      USER_GID: ${PGID}
      GITEA__server__ROOT_URL: ${GITEA_ROOT_URL}
      GITEA__server__HTTP_PORT: 3000
      GITEA__database__DB_TYPE: postgres
      GITEA__database__HOST: shared-postgres:5432
      GITEA__database__NAME: ${GITEA_DB_NAME}
      GITEA__database__USER: ${GITEA_DB_USER}
      GITEA__database__PASSWD: ${GITEA_DB_PASS}
      GITEA__service__DISABLE_REGISTRATION: true
    volumes:
      - /mnt/docker-ssd/docker/appdata/gitea:/data
    healthcheck:
      test: ["CMD-SHELL", "curl -sf http://127.0.0.1:3000/ || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

  # Run once to install git-crypt on the TrueNAS host (apt is blocked there).
  # Usage: docker compose --profile setup up git-crypt-init
  git-crypt-init:
    container_name: git-crypt-init
    image: debian:bookworm-slim
    profiles:
      - setup
    restart: "no"
    volumes:
      - /root/bin:/out
    command: >
      bash -c "
        apt-get update -qq &&
        apt-get install -y -qq git-crypt &&
        cp /usr/bin/git-crypt /out/git-crypt &&
        chmod +x /out/git-crypt &&
        echo 'git-crypt installed to /root/bin/git-crypt'
      "

  rackpeek:
    container_name: ix-rackpeek-rackpeek-1
    image: aptacode/rackpeek:latest
    restart: unless-stopped
    networks:
      - dev-net
      - pangolin
    ports:
      - "8283:8080"
    environment:
      TZ: ${TZ}
      RPK_YAML_DIR: /app/config
    volumes:
      - /mnt/docker-ssd/docker/compose/dev/rackpeek:/app/config
      - /mnt/tank/docker/appdata/app/rackpeek/dpkeys:/home/app/.aspnet/DataProtection-Keys
    healthcheck:
      test: ["CMD-SHELL", "cat /proc/net/tcp6 | grep -q 1F90 || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s
