version: "2.4"

volumes:
  database:
    name: city-db
  blockchain:
    name: city-data
  tipbot-blockchain:
    name: city-tipbot-data
  tipbot-database:
    name: city-tipbot-db
#  bws-database:
#    name: city-bws-db

services:

  # bwsnode:
  #   container_name: city-bws-node
  #   image: blockcore-bws-city
  #   command: ["node"]
  #   deploy:
  #     resources:
  #         limits:
  #             cpus: '0.200'
  #           memory: 256M
  #   environment:
  #     VIRTUAL_HOST: city.api.blockcore.net
  #     VIRTUAL_PORT: 3000
  #     VIRTUAL_PROTO: http
  #     VIRTUAL_NETWORK: proxy
  #     LETSENCRYPT_HOST: city.api.blockcore.net
  #     LETSENCRYPT_EMAIL: admin@blockcore.net
  #     DB_HOST: city-bws-mongo
  #   restart: unless-stopped
  #   depends_on:
  #     bwsmongo:
  #       condition: service_healthy
  #     chain:
  #       condition: service_healthy
  #   ports:
  #     #- 8100:8100
  #     - 3000:3000
  #   env_file:
  #     - bws.env
  #   networks:
  #     - citynetwork
  #     - proxy
  # bwsapi:
  #   # build: .
  #   tty: true
  #   container_name: city-bws-api
  #   image: blockcore-bws-city
  #   command: ["bws:start"]
  #   deploy:
  #     resources:
  #         limits:
  #             cpus: '0.200'
  #           memory: 2048M
  #   environment:
  #     VIRTUAL_HOST: city.bws.blockcore.net
  #     VIRTUAL_PORT: 3232
  #     VIRTUAL_PROTO: http
  #     VIRTUAL_NETWORK: proxy
  #     LETSENCRYPT_HOST: city.bws.blockcore.net
  #     LETSENCRYPT_EMAIL: admin@blockcore.net
  #     DB_HOST: city-bws-mongo
  #   restart: unless-stopped
  #   depends_on:
  #     bwsmongo:
  #       condition: service_healthy
  #     chain:
  #       condition: service_healthy
  #   ports:
  #     - 3232:3232
  #   env_file:
  #     - bws.env
  #   networks:
  #     - citynetwork
  #     - proxy

  # bwsinsight:
  #   container_name: city-bws-insight
  #   image: blockcore-bws-city
  #   command: ["insight:prod"]
  #   deploy:
  #     resources:
  #         limits:
  #             cpus: '0.200'
  #           memory: 256M
  #   environment:
  #     VIRTUAL_HOST: city.insight.blockcore.net
  #     VIRTUAL_PORT: 8200
  #     VIRTUAL_PROTO: http
  #     VIRTUAL_NETWORK: proxy
  #     LETSENCRYPT_HOST: city.insight.blockcore.net
  #     LETSENCRYPT_EMAIL: admin@blockcore.net
  #     DB_HOST: city-bws-mongo
  #   restart: unless-stopped
  #   depends_on:
  #     bwsmongo:
  #       condition: service_healthy
  #   ports:
  #     - 8200:8200
  #   env_file:
  #     - bws.env
  #   networks:
  #     - citynetwork
  #     - proxy

  # bwsmongo:
  #   container_name: city-bws-mongo
  #   image: mongo:3.6.18
  #   restart: unless-stopped
  #   stop_grace_period: 5m
  #   volumes:
  #     - bws-database:/data/db
  #     - bws-database:/data/configdb
  #   deploy:
  #     resources:
  #         limits:
  #             cpus: '0.200'
  #           memory: 2048M
  #   healthcheck:
  #     test: echo 'db.runCommand("ping").ok' | mongo mongo:27017/test --quiet
  #     interval: 10s
  #     timeout: 10s
  #     retries: 5
  #     start_period: 40s
  #   networks:
  #     - citynetwork
  #     - proxy

  explorer:
    container_name: city-explorer
    image: blockcore/explorer:0.2.28
    mem_limit: 256m
    cpus: 0.500
    environment:
      VIRTUAL_HOST: city.explorer.blockcore.net,explorer.city-chain.org
      VIRTUAL_PORT: 9911
      VIRTUAL_PROTO: http
      VIRTUAL_NETWORK: proxy
      LETSENCRYPT_HOST: city.explorer.blockcore.net,explorer.city-chain.org
      LETSENCRYPT_EMAIL: admin@blockcore.net
    command: ["--chain=CITY"]
    restart: unless-stopped
    networks:
      - citynetwork
      - proxy

  indexer:
    container_name: city-indexer
    image: blockcore/indexer:0.2.50
    mem_limit: 4096m
    cpus: 2.000
    environment:
      VIRTUAL_HOST: city.indexer.blockcore.net
      VIRTUAL_PORT: 9910
      VIRTUAL_PROTO: http
      VIRTUAL_NETWORK: proxy
      LETSENCRYPT_HOST: city.indexer.blockcore.net
      LETSENCRYPT_EMAIL: admin@blockcore.net
      ASPNETCORE_URLS: http://+:9910
      Logging__LogLevel__Default: Debug
    command: ["--chain=CITY"]
    restart: unless-stopped
    depends_on:
      mongo:
        condition: service_healthy
      chain:
        condition: service_healthy
    networks:
      - citynetwork
      - proxy

  chain:
    container_name: city-chain
    image: blockcore/node-multi:1.2.62
    mem_limit: 6144m
    cpus: 1.500
    healthcheck:
      test: curl --fail http://localhost:4335/api/Node/status || exit 1
      interval: 10s
      retries: 5
      start_period: 5s
      timeout: 10s
    command: ["--chain=CITY", "-server=1", "-txindex=1", "-iprangefiltering=0", "-addnode=95.217.210.13", "-addnode=82.65.168.4", "-addnode=195.201.16.145", "-addnode=185.252.79.75", "-rpcallowip=10.202.0.0/8", "-rpcallowip=10.201.0.0/8", "-rpcallowip=192.168.0.0/8", "-rpcallowip=172.0.0.0/8", "-whitelist=172.27.0.1", "-whitelist=172.27.0.2", "-whitelist=172.27.0.3", "-whitelist=172.27.0.4", "-whitelist=172.27.0.5", "-whitelist=172.27.0.6", "-whitelist=172.27.0.7", "-whitelist=172.27.0.8", "-whitelist=172.27.0.9", "-whitelist=172.27.0.10", "-whitelist=172.27.0.11", "-whitelist=172.27.0.12", "-whitelist=172.27.0.13", "-whitelist=172.27.0.14", "-whitelist=172.27.0.15", "-rpcbind=0.0.0.0", "-apiuri=http://0.0.0.0:4335", "-rpcuser=rpcuser", "-rpcpassword=rpcpassword"]
    restart: unless-stopped
    stop_grace_period: 15m
    volumes:
      - blockchain:/root/.blockcore
    ports:
      - 4333:4333 # Make this a public node.
      - 4335:4335
    networks:
      - citynetwork

  mongo:
    container_name: city-mongo
    image: mongo:5.0.12
    mem_limit: 4096m
    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:
      - database:/data/db
      - database:/data/configdb
    networks:
      - citynetwork

  # tipbot:
  #   container_name: city-tipbot
  #   image: blockcore/tipbot:0.1.8
  #   mem_limit: 1024m
  #   cpus: 0.200
  #   env_file:
  #     - tipbot.env
  #   command: ["--chain=CITY"]
  #   restart: unless-stopped
  #   depends_on:
  #     tipbot-database:
  #       condition: service_started
  #     tipbot-chain:
  #       condition: service_healthy
  #   networks:
  #     - citynetwork

  tipbot-chain:
    container_name: city-tipbot-chain
    image: blockcore/node-multi:1.2.62
    mem_limit: 6144m
    cpus: 0.200
    healthcheck:
      test: curl --fail http://localhost:4335/api/Node/status || exit 1
      interval: 10s
      retries: 5
      start_period: 5s
      timeout: 10s
    command: ["--chain=CITY", "-server=1", "-txindex=0", "-iprangefiltering=0", "-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", "-apiuri=http://0.0.0.0:4335", "-rpcuser=rpcuser", "-rpcpassword=rpcpassword"]
    restart: unless-stopped
    stop_grace_period: 15m
    volumes:
      - tipbot-blockchain:/root/.blockcore
    networks:
      - citynetwork

  tipbot-database:
    container_name: city-tipbot-db
    image: mcr.microsoft.com/mssql/server:2019-latest
    mem_limit: 2048m
    cpus: 0.500
    env_file:
      - tipbot.env
    environment:
      ACCEPT_EULA: "Y"
    restart: unless-stopped
    volumes:
      - tipbot-database:/var/opt/mssql
    networks:
      - citynetwork

networks:
  citynetwork:
    external: false
    name: citynetwork
  proxy:
    external: true
    name: proxy