# ============================================================
# thefeed-server — Docker Compose
# ============================================================
#
# Quick start (public channels, no Telegram login):
#   1. cp .env.example .env   (edit with your domain & key)
#   2. mkdir -p data && cp configs/channels.txt data/
#   3. docker compose up -d
#   4. Set up iptables to redirect external port 53 to 5300:
#      sudo iptables -t nat -I PREROUTING -i eth0 -p udp --dport 53 -j REDIRECT --to-ports 5300
#      sudo iptables -I INPUT -p udp --dport 5300 -j ACCEPT
#      (replace eth0 with your network interface — check with: ip a)
#
# With Telegram (one-time login first):
#   1. cp .env.example .env   (uncomment Telegram vars)
#   2. docker compose run -it --rm server \
#        --login-only --data-dir /data \
#        --domain ${THEFEED_DOMAIN} --key ${THEFEED_KEY} \
#        --api-id ${TELEGRAM_API_ID} --api-hash ${TELEGRAM_API_HASH} \
#        --phone ${TELEGRAM_PHONE}
#   3. Remove --no-telegram from the command below
#   4. docker compose up -d
#
# Logs:  docker compose logs -f
# Stop:  docker compose down
# ============================================================

services:
  server:
    build:
      context: .
      args:
        VERSION: ${VERSION:-docker}
        COMMIT: ${COMMIT:-unknown}
        DATE: ${DATE:-unknown}
    container_name: thefeed-server
    restart: unless-stopped
    ports:
      - "5300:5300/udp"
    volumes:
      - ./data:/data
    env_file:
      - .env
    command: >-
      --data-dir /data
      --listen :5300
      --domain ${THEFEED_DOMAIN}
      --key ${THEFEED_KEY}
      --no-telegram
    # To enable Telegram mode:
    # 1. Run login-only first (see instructions above)
    # 2. Replace the command above with:
    # command: >-
    #   --data-dir /data
    #   --listen :5300
    #   --domain ${THEFEED_DOMAIN}
    #   --key ${THEFEED_KEY}
    #   --api-id ${TELEGRAM_API_ID}
    #   --api-hash ${TELEGRAM_API_HASH}
    #   --phone ${TELEGRAM_PHONE}
