version: '3.9'
services:
  bitcoind:
    container_name: bitcoind
    image: lncm/bitcoind:v27.0
    user: 0:0
    volumes:
      - ${APP_DATA_DIR}/data:/root/.bitcoin
    ports:
      - ${APP_PORT}:8333
      - 8332:8332
      - 28332:28332
      - 28333:28333
    restart: unless-stopped
    stop_grace_period: 15m30s
    command: >-
      -dbcache=${BITCOIND_DB_CACHE:-450}
      -maxmempool=${BITCOIND_MAX_MEMPOOL:-300}
      -listen=${BITCOIND_LISTEN:-1}
      -server=${BITCOIND_SERVER:-1}
      -rpcallowip=0.0.0.0/0
      -rpcbind=0.0.0.0
      -prune=${BITCOIND_PRUNING:-0}
      -maxconnections=${BITCOIND_MAXPEERS:-125}
      -txindex=${BITCOIND_TXINDEX:-1}
      -peerbloomfilters=${BITCOIND_BLOOM_FILTERS:-1}
      -blockfilterindex=${BITCOIND_BLOCK_FILTER:-1}
      -peerblockfilters=${BITCOIND_BLOCK_FILTER:-1}
    networks:
      - tipi_main_network
    labels:
      # Main
      traefik.enable: true
      traefik.http.middlewares.bitcoind-web-redirect.redirectscheme.scheme: https
      traefik.http.services.bitcoind.loadbalancer.server.port: 3333
      # Web
      traefik.http.routers.bitcoind-insecure.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.bitcoind-insecure.entrypoints: web
      traefik.http.routers.bitcoind-insecure.service: bitcoind
      traefik.http.routers.bitcoind-insecure.middlewares: bitcoind-web-redirect
      # Websecure
      traefik.http.routers.bitcoind.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.bitcoind.entrypoints: websecure
      traefik.http.routers.bitcoind.service: bitcoind
      traefik.http.routers.bitcoind.tls.certresolver: myresolver
      # Local domain
      traefik.http.routers.bitcoind-local-insecure.rule: Host(`bitcoind.${LOCAL_DOMAIN}`)
      traefik.http.routers.bitcoind-local-insecure.entrypoints: web
      traefik.http.routers.bitcoind-local-insecure.service: bitcoind
      traefik.http.routers.bitcoind-local-insecure.middlewares: bitcoind-web-redirect
      # Local domain secure
      traefik.http.routers.bitcoind-local.rule: Host(`bitcoind.${LOCAL_DOMAIN}`)
      traefik.http.routers.bitcoind-local.entrypoints: websecure
      traefik.http.routers.bitcoind-local.service: bitcoind
      traefik.http.routers.bitcoind-local.tls: true