services:
  btcpayserver:
    image: btcpayserver/btcpayserver:2.2.0
    container_name: btcpayserver
    restart: unless-stopped
    ports:
      - "49392:49392"  # BTCPay Server HTTP port
    environment:
      # Database
      - POSTGRES_HOST=postgres
      - POSTGRES_PORT=5432
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-BTCPay2024SecurePassword123!}
      - POSTGRES_DB=btcpayserver
      
      # BTCPay Server Configuration
      - BTCPAY_HOST=pay.silverlabs.uk
      - BTCPAY_PROTOCOL=https
      - BTCPAY_BIND=0.0.0.0:49392
      
      # Network settings
      - BTCPAY_NETWORK=mainnet
      - BTCPAY_CHAINS=btc
      - BTCPAY_BTCEXPLORERURL=http://nbxplorer:32838
      
      # Other settings  
      - BTCPAY_ROOTPATH=/
      - BTCPAY_DEBUGLOG=btcpay.log
      - BTCPAY_LOGS_LEVEL=info
      
    volumes:
      - btcpay_datadir:/datadir
      - btcpay_logs:/var/log/btcpayserver
    networks:
      - btcpaynetwork
    depends_on:
      - postgres
      - nbxplorer

  postgres:
    image: postgres:13
    container_name: btcpay-postgres
    restart: unless-stopped
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-BTCPay2024SecurePassword123!}
      - POSTGRES_DB=btcpayserver
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - btcpaynetwork

  nbxplorer:
    image: nicolasdorier/nbxplorer:2.5.30
    container_name: btcpay-nbxplorer
    restart: unless-stopped
    ports:
      - "32838:32838"
    environment:
      - NBXPLORER_NETWORK=mainnet
      - NBXPLORER_CHAINS=btc
      - NBXPLORER_BTCRPCURL=http://bitcoind:8332
      - NBXPLORER_BTCRPCUSER=bitcoinrpc
      - NBXPLORER_BTCRPCPASSWORD=${BTC_RPC_PASSWORD:-BitcoinRPC2024SecurePassword456!}
      - NBXPLORER_BIND=0.0.0.0:32838
      - NBXPLORER_VERBOSE=1
      - NBXPLORER_NOAUTH=1
      - POSTGRES_HOST=postgres
      - POSTGRES_PORT=5432
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-BTCPay2024SecurePassword123!}
      - POSTGRES_DB=nbxplorer
    volumes:
      - nbxplorer_data:/datadir
    networks:
      - btcpaynetwork
    depends_on:
      - bitcoind

  bitcoind:
    image: btcpayserver/bitcoin:26.0
    container_name: btcpay-bitcoind
    restart: unless-stopped
    command: >
      bitcoind
      -server=1
      -rpcuser=bitcoinrpc
      -rpcpassword=${BTC_RPC_PASSWORD:-BitcoinRPC2024SecurePassword456!}
      -rpcbind=0.0.0.0:8332
      -rpcallowip=0.0.0.0/0
      -txindex=1
      -prune=0
    volumes:
      - bitcoin_data:/home/bitcoin/.bitcoin
    networks:
      - btcpaynetwork
    ports:
      - "8333:8333"  # Bitcoin P2P
      - "8332:8332"  # Bitcoin RPC (internal only)

volumes:
  btcpay_datadir:
    driver: local
  btcpay_logs:
    driver: local
  postgres_data:
    driver: local
  nbxplorer_data:
    driver: local
  bitcoin_data:
    driver: local

networks:
  btcpaynetwork:
    driver: bridge