version: "2.4"

# volumes:
#   prometheus-data:
#     driver: local
#     driver_opts:
#       o: bind
#       type: none
#       device: /disk1/prometheus-data

services:
  indexer:
    container_name: btc-indexer
    image: blockcore/indexer:0.2.50
    mem_limit: 8192m
    cpus: 2.000
    environment:
      VIRTUAL_HOST: btc.indexer.blockcore.net
      VIRTUAL_PORT: 9910
      VIRTUAL_PROTO: http
      VIRTUAL_NETWORK: proxy
      LETSENCRYPT_HOST: btc.indexer.blockcore.net
      LETSENCRYPT_EMAIL: admin@blockcore.net
      ASPNETCORE_URLS: http://+:9910
    command: ["--chain=BTC"]
    restart: unless-stopped
    depends_on:
      mongo:
        condition: service_healthy
      # chain:
      #   condition: service_healthy
    networks:
      - btcnetwork
      - proxy

  chain:
    container_name: btc-chain
    user: 1000:1000
    image: lncm/bitcoind:v25.0
    mem_limit: 8192m
    cpus: 2.000
    # healthcheck:
    #   test: curl --fail http://localhost:8332/rest/chaininfo.json || exit 1
    #   interval: 10s
    #   retries: 10
    #   start_period: 5s
    #   timeout: 10s
    command:
      [
        "-server=1",
        "-rest=1",
        "-txindex=1",
        "-dbcache=6000",
        "-rpcworkqueue=100",
        "-rpcthreads=100",
        "-addresstype=bech32",
        "-changetype=bech32",
        "-rpcallowip=10.202.0.0/8",
        "-rpcallowip=10.201.0.0/8",
        "-rpcallowip=192.168.0.0/8",
        "-rpcallowip=172.0.0.0/8",
        "-rpcbind=0.0.0.0",
        "-rpcuser=rpcuser",
        "-rpcpassword=rpcpassword",
        "-assumevalid=000000000000000000039f849372dbe650f8b9a17e7aba7a8e022aaf41280b8d",
      ]
    restart: on-failure
    stop_grace_period: 15m30s
    volumes:
      - /mnt/data/.bitcoin:/data/.bitcoin
    ports:
      - "8333:8333"
      - "8332:8332"
      - "28332:28332"
      - "28333:28333"
    networks:
      - btcnetwork

  mongo:
    container_name: btc-mongo
    image: mongo:5.0.12
    mem_limit: 8192m
    cpus: 2.000

    healthcheck:
      test: echo 'db.runCommand("ping").ok' | mongo mongo:27017/test --quiet
      interval: 10s
      timeout: 10s
      retries: 5
      start_period: 40s

    restart: unless-stopped
    stop_grace_period: 5m
    volumes:
      - /mnt/data/blockcore/btc:/data/db
      - /mnt/data/blockcore/btc:/data/configdb
    networks:
      - btcnetwork

networks:
  btcnetwork:
    external: false
    name: btcnetwork
  proxy:
    external: true
    name: proxy
