version: '3.8'

services:
  telebot:
    build:
      context: ../
      dockerfile: TeleBot/TeleBot/Dockerfile
    container_name: littleshop-telebot
    restart: unless-stopped
    
    environment:
      - DOTNET_ENVIRONMENT=Production
      - TZ=UTC
      
      # Telegram Bot Configuration
      - Telegram__BotToken=${TELEGRAM_BOT_TOKEN}
      - Telegram__AdminChatId=${TELEGRAM_ADMIN_CHAT_ID}
      - Telegram__UseWebhook=false
      
      # LittleShop API Configuration  
      - LittleShop__ApiUrl=${LITTLESHOP_API_URL:-https://host.docker.internal:5001}
      - LittleShop__Username=${LITTLESHOP_USERNAME:-admin}
      - LittleShop__Password=${LITTLESHOP_PASSWORD:-admin}
      - LittleShop__UseTor=false
      
      # Privacy Settings
      - Privacy__Mode=strict
      - Privacy__DataRetentionHours=24
      - Privacy__SessionTimeoutMinutes=30
      - Privacy__EnableAnalytics=false
      - Privacy__EphemeralByDefault=true
      - Privacy__EnableTor=false
      
      # Database Configuration
      - Database__ConnectionString=Filename=/app/data/telebot.db;Password=;
      - Database__EncryptionKey=${DATABASE_ENCRYPTION_KEY}
      
      # Features
      - Features__EnableQRCodes=true
      - Features__EnablePGPEncryption=true
      - Features__EnableDisappearingMessages=true
      
      # Redis (optional)
      - Redis__Enabled=${REDIS_ENABLED:-false}
      - Redis__ConnectionString=${REDIS_CONNECTION_STRING:-redis:6379}
      
      # Hangfire (optional)
      - Hangfire__Enabled=${HANGFIRE_ENABLED:-false}
    
    volumes:
      - telebot-data:/app/data
      - telebot-logs:/app/logs
    
    networks:
      - littleshop-network
    
    healthcheck:
      test: ["CMD", "pgrep", "-f", "dotnet.*TeleBot"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    
    depends_on:
      - redis
    
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

  redis:
    image: redis:7-alpine
    container_name: littleshop-redis
    restart: unless-stopped
    
    command: redis-server --requirepass ${REDIS_PASSWORD}
    
    volumes:
      - redis-data:/data
    
    networks:
      - littleshop-network
    
    healthcheck:
      test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
      interval: 30s
      timeout: 3s
      retries: 5
    
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

volumes:
  telebot-data:
    name: littleshop-telebot-data
  telebot-logs:
    name: littleshop-telebot-logs
  redis-data:
    name: littleshop-redis-data

networks:
  littleshop-network:
    name: littleshop-network
    driver: bridge