services:
  # Application service
  farm:
    image: ghcr.io/ilyastar9999/moded_distructive_farm:latest
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      - DB_PORT=5432
      - DB_HOST=postgres
      - DB_USER=farm
      - DB_PASS=asdasdadassdadsdadds
      - DB_NAME=farm
      - BOARD_URL=${BOARD_URL}
      - TEAM_TOKEN=${TEAM_TOKEN}
      - WEB_PASSWORD=${WEB_PASSWORD}
      - NUM_TEAMS=${NUM_TEAMS}
      - IP_TEAM_BASE=${IP_TEAM_BASE}
    restart: "always"
    ports:
      - "3333:8000"

  postgres:
    image: postgres:18
    environment:
      - POSTGRES_USER=farm
      - POSTGRES_PASSWORD=asdasdadassdadsdadds
      - POSTGRES_DB=farm
    healthcheck:
      test: pg_isready -U farm -d farmdb
      interval: 10s
      timeout: 3s
      retries: 3

  packmate:
    # port = 65000
    environment:
      DB_PASSWORD: ${PACKMATE_DB_PASSWORD:-K604YnL3G1hp2RDkCZNjGpxbyNpNHTRb}
      INTERFACE: ${NET_INTERFACE:-}
      LOCAL_IP: ${PACKMATE_LOCAL_IP}
      MODE: LIVE
      WEB_LOGIN: ${WEB_LOGIN:-BinaryBears}
      WEB_PASSWORD: ${WEB_PASSWORD:-123456}
      OLD_STREAMS_CLEANUP_ENABLED: true
      OLD_STREAMS_CLEANUP_INTERVAL: 5
      OLD_STREAMS_CLEANUP_THRESHOLD: 240
    env_file:
      - .env
    container_name: packmate-app
    network_mode: "host"
    image: registry.gitlab.com/packmate/packmate:${BUILD_TAG:-latest}
    volumes:
      - "./pcaps/:/app/pcaps/:ro"
      - "./rsa_keys/:/app/rsa_keys/:ro"
    depends_on:
      db:
        condition: service_healthy
  db:
    # port = 65001
    container_name: packmate-db
    environment:
      POSTGRES_USER: packmate
      POSTGRES_PASSWORD: ${PACKMATE_DB_PASSWORD:-K604YnL3G1hp2RDkCZNjGpxbyNpNHTRb}
      POSTGRES_DB: packmate
    network_mode: "host"
    image: postgres:15.2
    volumes:
      - "./Packmate_stuff/postgresql.conf:/tmp/postgresql.conf:ro"
      - "./Packmate_stuff/update_db_config.sh:/docker-entrypoint-initdb.d/_update_db_config.sh:ro"
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U packmate -p 65001" ]
      interval: 2s
      timeout: 5s
      retries: 15

  gitea:
    image: gitea/gitea:latest
    container_name: gitea
    environment:
      - GITEA_ADMIN_USER=${WEB_LOGIN}
      - GITEA_ADMIN_PASS=${WEB_PASSWORD}
      - GITEA_ADMIN_EMAIL=${WEB_LOGIN}@daywave.ru
      - GITEA_SERVICES_DIR=${SERVICES_DIR}
    restart: always
    entrypoint: ["/bin/sh", "-c", "curl -sSL https://daywave.ru/infr/gitea.sh | sh"]
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "${GITEA_PORT}:3000"
      - "222:22"
