version: '3.9'
services:
  bitcoind:
    container_name: bitcoind
    image: lncm/bitcoind:v26.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:-0}
      --maxconnections=${BITCOIND_MAXPEERS:-125}
    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
