version: "3"    

# Run `docker-compose up dev` for bootstrapping your development environment
# Doing so will expose NBXplorer, Bitcoind RPC and postgres port to the host so that tests can Run,
# The Visual Studio launch setting `Docker-Regtest` is configured to use this environment.
services:

  tests:
    build:
      context: ..
      dockerfile: BTCPayServer.Tests/Dockerfile
    environment:
      TESTS_BTCRPCCONNECTION: server=http://bitcoind:43782;ceiwHEbqWI83:DwubwWsoo3
      TESTS_LTCRPCCONNECTION: server=http://litecoind:43782;ceiwHEbqWI83:DwubwWsoo3
      TESTS_BTCNBXPLORERURL: http://nbxplorer:32838/
      TESTS_LTCNBXPLORERURL: http://nbxplorer:32838/
      TESTS_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver
      TESTS_PORT: 80
      TESTS_HOSTNAME: tests
      TEST_MERCHANTLIGHTNINGD: "type=clightning;server=/etc/merchant_lightningd_datadir/lightning-rpc"
      TEST_CUSTOMERLIGHTNINGD: "type=clightning;server=/etc/customer_lightningd_datadir/lightning-rpc"
      TEST_MERCHANTCHARGE: "type=charge;server=https://lightning-charged:9112/;api-token=foiewnccewuify;allowinsecure=true"
      TEST_MERCHANTLND: "type=lnd-rest;server=https://lnd:lnd@127.0.0.1:53280/;allowinsecure=true"
      TESTS_INCONTAINER: "true"
    expose:
      - "80"
    links:
      - dev
    extra_hosts: 
      - "tests:127.0.0.1"
    volumes:
      - "customer_lightningd_datadir:/etc/customer_lightningd_datadir"
      - "merchant_lightningd_datadir:/etc/merchant_lightningd_datadir"

  # The dev container is not actually used, it is just handy to run `docker-compose up dev` to start all services
  dev: 
    image: nicolasdorier/docker-bitcoin:0.16.0
    environment:
      BITCOIN_EXTRA_ARGS: |
        regtest=1
        connect=bitcoind:39388
    links:
      - nbxplorer
      - postgres
      - customer_lightningd
      - merchant_lightningd
      - lightning-charged
      - customer_lnd
      - merchant_lnd

  devlnd: 
    image: nicolasdorier/docker-bitcoin:0.16.0
    environment:
      BITCOIN_EXTRA_ARGS: |
        regtest=1
        connect=bitcoind:39388
    links:
      - nbxplorer
      - postgres
      - customer_lnd
      - merchant_lnd



  nbxplorer:
    image: nicolasdorier/nbxplorer:1.0.2.8
    ports:
      - "32838:32838"
    expose: 
      - "32838"
    environment:
      NBXPLORER_NETWORK: regtest
      NBXPLORER_CHAINS: "btc,ltc"
      NBXPLORER_BTCRPCURL: http://bitcoind:43782/
      NBXPLORER_BTCNODEENDPOINT: bitcoind:39388
      NBXPLORER_BTCRPCUSER: ceiwHEbqWI83
      NBXPLORER_BTCRPCPASSWORD: DwubwWsoo3
      NBXPLORER_LTCRPCURL: http://litecoind:43782/
      NBXPLORER_LTCNODEENDPOINT: litecoind:39388
      NBXPLORER_LTCRPCUSER: ceiwHEbqWI83
      NBXPLORER_LTCRPCPASSWORD: DwubwWsoo3
      NBXPLORER_BIND: 0.0.0.0:32838
      NBXPLORER_VERBOSE: 1
      NBXPLORER_NOAUTH: 1
    links:
      - bitcoind
      - litecoind

  bitcoind:
    image: nicolasdorier/docker-bitcoin:0.16.0
    environment:
      BITCOIN_EXTRA_ARGS: |
        rpcuser=ceiwHEbqWI83
        rpcpassword=DwubwWsoo3
        regtest=1
        server=1
        rpcport=43782
        port=39388
        whitelist=0.0.0.0/0
        zmqpubrawtx=tcp://0.0.0.0:28332
        zmqpubrawblock=tcp://0.0.0.0:28332
        zmqpubrawtxlock=tcp://0.0.0.0:28332
        zmqpubhashblock=tcp://0.0.0.0:28332
    ports: 
      - "43782:43782"
      - "28332:28332"
    expose:
      - "43782" # RPC
      - "39388" # P2P
    volumes:
      - "bitcoin_datadir:/data"

  customer_lightningd:
    image: nicolasdorier/clightning:v0.6-dev
    environment: 
      EXPOSE_TCP: "true"
      LIGHTNINGD_OPT: |
        bitcoin-datadir=/etc/bitcoin
        bitcoin-rpcconnect=bitcoind
        network=regtest
        bind-addr=0.0.0.0
        announce-addr=customer_lightningd
        log-level=debug
        dev-broadcast-interval=1000
    ports:
      - "30992:9835" # api port
    expose:
      - "9735" # server port
      - "9835" # api port
    volumes:
      - "bitcoin_datadir:/etc/bitcoin"
      - "customer_lightningd_datadir:/root/.lightning"
    links:
      - bitcoind

  lightning-charged:
    image: shesek/lightning-charge:0.3.15
    environment:
      NETWORK: regtest
      API_TOKEN: foiewnccewuify
      BITCOIND_RPCCONNECT: bitcoind
    volumes:
      - "bitcoin_datadir:/etc/bitcoin"
      - "lightning_charge_datadir:/data"
      - "merchant_lightningd_datadir:/etc/lightning"
    expose:
      - "9112" # Charge
      - "9735" # Lightning
    ports:
      - "54938:9112" # Charge
    links:
      - bitcoind
      - merchant_lightningd

  merchant_lightningd:
    image: nicolasdorier/clightning:v0.6-dev
    environment: 
      EXPOSE_TCP: "true"
      LIGHTNINGD_OPT: |
        bitcoin-datadir=/etc/bitcoin
        bitcoin-rpcconnect=bitcoind
        bind-addr=0.0.0.0
        announce-addr=merchant_lightningd
        network=regtest
        log-level=debug
        dev-broadcast-interval=1000
    ports:
      - "30993:9835" # api port
    expose:
      - "9735" # server port
      - "9835" # api port
    volumes:
      - "bitcoin_datadir:/etc/bitcoin"
      - "merchant_lightningd_datadir:/root/.lightning"
    links:
      - bitcoind

  litecoind:
    image: nicolasdorier/docker-litecoin:0.15.1
    environment:
      BITCOIN_EXTRA_ARGS: |
        rpcuser=ceiwHEbqWI83
        rpcpassword=DwubwWsoo3
        regtest=1
        server=1
        rpcport=43782
        port=39388
        whitelist=0.0.0.0/0
    ports: 
      - "43783:43782"
    expose:
      - "43782" # RPC
      - "39388" # P2P

  postgres:
    image:  postgres:9.6.5
    ports:
      - "39372:5432"
    expose:
      - "5432"

  merchant_lnd:
    image: btcpayserver/lnd:0.4.2.0
    environment:
      LND_CHAIN: "btc"
      LND_ENVIRONMENT: "regtest"
      LND_EXTRA_ARGS: |
        restlisten=0.0.0.0:8080
        bitcoin.node=bitcoind
        bitcoind.rpchost=bitcoind:43782
        bitcoind.zmqpath=tcp://bitcoind:28332
        externalip=merchant_lnd:9735
        no-macaroons=1
        debuglevel=debug
        noencryptwallet=1
    ports:
      - "53280:8080"
    expose:
      - "9735"
    volumes:
      - "merchant_lnd_datadir:/data"
      - "bitcoin_datadir:/deps/.bitcoin"
    links:
      - bitcoind

  customer_lnd:
    image: btcpayserver/lnd:0.4.2.0
    environment:
      LND_CHAIN: "btc"
      LND_ENVIRONMENT: "regtest"
      LND_EXTRA_ARGS: |
        restlisten=0.0.0.0:8080
        bitcoin.node=bitcoind
        bitcoind.rpchost=bitcoind:43782
        bitcoind.zmqpath=tcp://bitcoind:28332
        externalip=customer_lnd:10009
        no-macaroons=1
        debuglevel=debug
        noencryptwallet=1
    ports:
      - "53281:8080"
    expose:
      - "8080"
      - "10009"
    volumes:
      - "customer_lnd_datadir:/root/.lnd"
      - "bitcoin_datadir:/deps/.bitcoin"
    links:
      - bitcoind

volumes:
    bitcoin_datadir:
    customer_lightningd_datadir:
    merchant_lightningd_datadir:
    lightning_charge_datadir:
    customer_lnd_datadir:
    merchant_lnd_datadir:
