# This will expose BTCPayServer, Woocommerce, your lightning nodes as hidden services and accept onion peers for your full node.
# Warning: This options is for working around NAT and firewall problems as well as to help protect your customer's privacy.
# This will not protect your privacy against a targeted attack against your own privacy.
# All outbound traffic is not channeled through the TOR SOCKS proxy
version: "3"

services:

  btcpayserver:
    environment:
      HIDDENSERVICE_NAME: BTCPayServer
      HIDDENSERVICE_REVERSEPROXY: nginx
      BTCPAY_TORRCFILE: /usr/local/etc/tor/torrc-2
      BTCPAY_SOCKSENDPOINT: tor:9050
    volumes:
      - "tor_servicesdir:/var/lib/tor/hidden_services"
      - "tor_torrcdir:/usr/local/etc/tor/"

  btctransmuter:
    environment:
      HIDDENSERVICE_NAME: BTCTransmuter
      HIDDENSERVICE_REVERSEPROXY: nginx
      TRANSMUTER_TORRCFILE: /usr/local/etc/tor/torrc-2
      TRANSMUTER_SOCKSENDPOINT: tor:9050
    volumes:
      - "tor_servicesdir:/var/lib/tor/hidden_services"
      - "tor_torrcdir:/usr/local/etc/tor/"

  configurator:
    environment:
      HIDDENSERVICE_NAME: Configurator
      HIDDENSERVICE_REVERSEPROXY: nginx
    volumes:
      - "tor_servicesdir:/var/lib/tor/hidden_services"
      - "tor_torrcdir:/usr/local/etc/tor/"

  woocommerce:
    environment:
      HIDDENSERVICE_NAME: WooCommerce
      WOOCOMMERCE_HIDDENSERVICE_HOSTNAME_FILE: /var/lib/tor/hidden_services/WooCommerce/hostname
    volumes:
      - "tor_servicesdir:/var/lib/tor/hidden_services"

  bitcoind:
    environment:
      HIDDENSERVICE_NAME: BTC-P2P,BTC-RPC
      BTC-P2P_HIDDENSERVICE_VIRTUAL_PORT: 8333
      BTC-P2P_HIDDENSERVICE_PORT: 39388
      BTC-RPC_HIDDENSERVICE_VIRTUAL_PORT: 8332
      BTC-RPC_HIDDENSERVICE_PORT: 43782
      BITCOIN_EXTRA_ARGS: |
        onion=tor:9050
        # rpcuser=btcrpc
        # rpcpassword=btcpayserver4ever
        # We need to use rpcauth because we also need cookieauth. rpcpassword disabled cookie file auth.
        # Be careful if you copy the line below from the docker-compose.yml! A dollar sign is escaped.
        rpcauth=btcrpc:a6a5d29a3f44f02e4cd8cabb5b10a234$$ab6152915515f6a9cca806d2ab5f0e2794c346ba74f812c61e48241d523778b8
    volumes:
      - "tor_datadir:/home/tor/.tor"
    links:
      - tor

  nginx:
    volumes:
      - "tor_servicesdir:/var/lib/tor/hidden_services"
  nginx-gen:
    volumes:
      - "tor_servicesdir:/var/lib/tor/hidden_services"

  tor:
    restart: unless-stopped
    image: btcpayserver/tor:0.4.7.10
    container_name: tor
    environment:
      TOR_PASSWORD: btcpayserver
      TOR_ADDITIONAL_CONFIG: /usr/local/etc/tor/torrc-2
      TOR_EXTRA_ARGS: |
        CookieAuthentication 1
    expose:
      - "9050"  # SOCKS
      - "9051"  # Tor Control
    volumes:
      - "tor_datadir:/home/tor/.tor"
      - "tor_torrcdir:/usr/local/etc/tor"
      - "tor_servicesdir:/var/lib/tor/hidden_services"

  clightning_bitcoin:
    environment:
      HIDDENSERVICE_NAME: c-lightning
      HIDDENSERVICE_PORT: 9735
      LIGHTNINGD_HIDDENSERVICE_HOSTNAME_FILE: /var/lib/tor/hidden_services/c-lightning/hostname
      LIGHTNINGD_OPT: |
        proxy=tor:9050
    volumes:
      - "tor_servicesdir:/var/lib/tor/hidden_services"
    links:
      - tor
  clightning_litecoin:
    environment:
      HIDDENSERVICE_NAME: c-lightning-ltc
      HIDDENSERVICE_PORT: 9736
      LIGHTNINGD_HIDDENSERVICE_HOSTNAME_FILE: /var/lib/tor/hidden_services/c-lightning-ltc/hostname
      LIGHTNINGD_OPT: |
        proxy=tor:9050
    volumes:
      - "tor_servicesdir:/var/lib/tor/hidden_services"
    links:
      - tor

  tor-gen:
    restart: unless-stopped
    image: btcpayserver/docker-gen:0.7.8
    container_name: tor-gen
    volumes:
      - "/var/run/docker.sock:/tmp/docker.sock:ro"
      - "./torrc.tmpl:/etc/docker-gen/templates/torrc.tmpl:ro"
      - "tor_torrcdir:/usr/local/etc/tor"
    entrypoint: /usr/local/bin/docker-gen -notify-sighup tor -watch -wait 5s:30s /etc/docker-gen/templates/torrc.tmpl /usr/local/etc/tor/torrc-2
    links:
      - tor

  lnd_bitcoin:
    environment:
      HIDDENSERVICE_NAME: lnd
      HIDDENSERVICE_PORT: 9735
      LND_HIDDENSERVICE_HOSTNAME_FILE: /var/lib/tor/hidden_services/lnd/hostname
      LND_EXTRA_ARGS: |
        tor.active=1
        tor.skip-proxy-for-clearnet-targets=1
        tor.socks=tor:9050
    links:
      - tor
    volumes:
      - "tor_datadir:/home/tor/.tor"
      - "tor_servicesdir:/var/lib/tor/hidden_services"

  lnd_litecoin:
    environment:
      HIDDENSERVICE_NAME: lnd-ltc
      HIDDENSERVICE_PORT: 9736
      LND_HIDDENSERVICE_HOSTNAME_FILE: /var/lib/tor/hidden_services/lnd-ltc/hostname
      LND_EXTRA_ARGS: |
        tor.active=1
        tor.socks=tor:9050
    links:
      - tor
    volumes:
      - "tor_datadir:/home/tor/.tor"
      - "tor_servicesdir:/var/lib/tor/hidden_services"

  electrum_ps:
    environment:
      HIDDENSERVICE_NAME: btc-electrum-ps
      HIDDENSERVICE_PORT: 50002
      HIDDENSERVICE_VIRTUAL_PORT: 50002

  electrumx:
    environment:
      HIDDENSERVICE_NAME: electrumx
      HIDDENSERVICE_PORT: 50002
      HIDDENSERVICE_VIRTUAL_PORT: 50002

  bwt:
    environment:
      HIDDENSERVICE_NAME: bwt-electrum
      HIDDENSERVICE_PORT: 50001
      HIDDENSERVICE_VIRTUAL_PORT: 50001

  bitcoin_teos:
    environment:
      HIDDENSERVICE_NAME: teos
      HIDDENSERVICE_PORT: 9814
    volumes:
      - "tor_servicesdir:/var/lib/tor/hidden_services"
      - "tor_torrcdir:/usr/local/etc/tor/"

  zammad-nginx:
    environment:
      HIDDENSERVICE_NAME: zammad
      HIDDENSERVICE_PORT: 80
    volumes:
      - "tor_servicesdir:/var/lib/tor/hidden_services"
      - "tor_torrcdir:/usr/local/etc/tor/"

  bitcoin_thub:
    environment:
      TOR_PROXY_SERVER: socks://tor:9050
volumes:
  tor_datadir:
  tor_torrcdir:
  tor_servicesdir:
