services:
  palladiumd:
    build:
      context: .
      dockerfile: Dockerfile.palladium-node
    image: palladium-node:local
    container_name: palladium-node
    restart: unless-stopped
    ports:
      - "0.0.0.0:2332:2332"  # RPC port mainnet (accessible from network)
      - "0.0.0.0:2333:2333"  # P2P port mainnet (accessible from network)
      - "0.0.0.0:28332:28332"  # ZMQ hashblock (accessible from network)
      - "0.0.0.0:28334:28334"  # ZMQ rawblock (accessible from network)
      - "0.0.0.0:28335:28335"  # ZMQ rawtx (accessible from network)
      # For testnet, expose: 12332 (RPC) and 12333 (P2P)

    volumes:
      # Mount palladium-node-data folder (contains config and blockchain data)
      - ./palladium-node-data:/root/.palladium

    command: >
      palladiumd
      -conf=/root/.palladium/palladium.conf
      -datadir=/root/.palladium
      -rpcbind=0.0.0.0
      -rpcallowip=0.0.0.0/0
      -daemon=0
      -printtoconsole=1

  electrumx:
    build:
      context: .
      dockerfile: Dockerfile.electrumx
    image: electrumx-server:local
    container_name: electrumx-server
    restart: unless-stopped
    depends_on:
      - palladiumd
    ports:
      - "0.0.0.0:50001:50001"  # TCP (accessible from network)
      - "0.0.0.0:50002:50002"  # SSL (accessible from network)

    environment:
      # ===== Network Configuration =====
      # For MAINNET use: COIN: "Palladium", NET: "mainnet"
      # For TESTNET use: COIN: "Palladium", NET: "testnet"

      COIN: "Palladium"  # Always "Palladium" for both networks
      NET: "mainnet"

      # NOTE: RPC credentials are automatically read from palladium.conf
      # No need to configure DAEMON_URL manually anymore!

      SERVICES: "tcp://0.0.0.0:50001,ssl://0.0.0.0:50002"

      SSL_CERTFILE: "/certs/server.crt"
      SSL_KEYFILE: "/certs/server.key"

      DB_DIRECTORY: "/data"
      PEER_DISCOVERY: "off"
      PEER_ANNOUNCE: "false"
      INITIAL_CONCURRENT: "2"
      COST_SOFT_LIMIT: "0"
      COST_HARD_LIMIT: "0"

    ulimits:
      nofile:
        soft: 1048576
        hard: 1048576

    volumes:
      - ./electrumx-data:/data
      - ./palladium-node-data/palladium.conf:/palladium-config/palladium.conf:ro