# Docker Compose for Stella's Nostr Relay
# Owner: npub1v30tsz9vw6ylpz63g0a702nj3xa26t3m7p5us8f2y2sd8v6cnsvq465zjx

services:
  orly-relay:
    build:
      context: ../..
      dockerfile: Dockerfile
    image: silberengel/next-orly:latest
    container_name: orly-relay
    restart: unless-stopped
    ports:
      - "127.0.0.1:7777:7777"
    volumes:
      - relay_data:/data
      - ./profiles:/profiles:ro
    environment:
      # Relay Configuration
      - ORLY_DATA_DIR=/data
      - ORLY_LISTEN=0.0.0.0
      - ORLY_PORT=7777
      - ORLY_LOG_LEVEL=info
      - ORLY_DB_LOG_LEVEL=error
      - ORLY_OWNERS=npub1v30tsz9vw6ylpz63g0a702nj3xa26t3m7p5us8f2y2sd8v6cnsvq465zjx
      - ORLY_ADMINS=npub1v30tsz9vw6ylpz63g0a702nj3xa26t3m7p5us8f2y2sd8v6cnsvq465zjx,npub1m4ny6hjqzepn4rxknuq94c2gpqzr29ufkkw7ttcxyak7v43n6vvsajc2jl,npub1l5sga6xg72phsz5422ykujprejwud075ggrr3z2hwyrfgr7eylqstegx9z

      # ACL and Spider Configuration
      - ORLY_ACL_MODE=follows

      # Bootstrap relay URLs for initial sync
      - ORLY_BOOTSTRAP_RELAYS=wss://profiles.nostr1.com,wss://purplepag.es,wss://relay.damus.io

      # Subscription Settings (optional)
      - ORLY_SUBSCRIPTION_ENABLED=false
      - ORLY_MONTHLY_PRICE_SATS=0

      # Performance Settings
      - ORLY_MAX_CONNECTIONS=1000
      - ORLY_MAX_EVENT_SIZE=65536
      - ORLY_MAX_SUBSCRIPTIONS=20

    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7777"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s

    # Resource limits
    deploy:
      resources:
        limits:
          memory: 1G
          cpus: "1.0"
        reservations:
          memory: 256M
          cpus: "0.25"

    # Logging configuration
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

  # Optional: Nginx reverse proxy for SSL/domain setup
  nginx:
    image: nginx:alpine
    container_name: stella-nginx
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./nginx/ssl:/etc/nginx/ssl:ro
      - nginx_logs:/var/log/nginx
    depends_on:
      - orly-relay
    profiles:
      - proxy # Only start with: docker-compose --profile proxy up

volumes:
  relay_data:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: ./data
  nginx_logs:
    driver: local

networks:
  default:
    name: orly-relay-network
