services:
  btcpayserver:
    restart: unless-stopped
    container_name: generated_btcpayserver_1
    image: ${BTCPAY_IMAGE:-btcpayserver/btcpayserver:1.13.3-altcoins}
    expose:
      - '49392'
    environment:
      BTCPAY_POSTGRES: User ID=postgres;Host=btcpay-postgres;Port=5432;Application Name=btcpayserver;Database=btcpayserver${NBITCOIN_NETWORK:-mainnet}
      BTCPAY_EXPLORERPOSTGRES: User ID=postgres;Host=btcpay-postgres;Port=5432;Application Name=btcpayserver;MaxPoolSize=80;Database=nbxplorer${NBITCOIN_NETWORK:-mainnet}
      BTCPAY_NETWORK: ${NBITCOIN_NETWORK:-mainnet}
      BTCPAY_BIND: 0.0.0.0:49392
      BTCPAY_ROOTPATH: ${BTCPAY_ROOTPATH:-/}
      BTCPAY_SSHCONNECTION: 'root@host.docker.internal'
      BTCPAY_SSHTRUSTEDFINGERPRINTS: ${BTCPAY_SSHTRUSTEDFINGERPRINTS}
      BTCPAY_SSHKEYFILE: ${BTCPAY_SSHKEYFILE}
      BTCPAY_SSHAUTHORIZEDKEYS: ${BTCPAY_SSHAUTHORIZEDKEYS}
      BTCPAY_DEBUGLOG: btcpay.log
      BTCPAY_UPDATEURL: https://api.github.com/repos/btcpayserver/btcpayserver/releases/latest
      BTCPAY_DOCKERDEPLOYMENT: 'true'
      BTCPAY_CHAINS: 'xmr'
      BTCPAY_XMR_DAEMON_URI: http://xmr-node.cakewallet.com:18081
      BTCPAY_XMR_WALLET_DAEMON_URI: http://monerod_wallet:18082
      BTCPAY_XMR_WALLET_DAEMON_WALLETDIR: /root/xmr_wallet
    labels:
      traefik.enable: 'true'
      traefik.http.routers.btcpayserver.rule: Host(`${BTCPAY_HOST}`)
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    links:
      - btcpay-postgres
    volumes:
      - 'btcpay_datadir:/datadir'
      - 'nbxplorer_datadir:/root/.nbxplorer'
      - 'btcpay_pluginsdir:/root/.btcpayserver/Plugins'
      - 'xmr_wallet:/root/xmr_wallet'
      - 'tor_servicesdir:/var/lib/tor/hidden_services'
      - 'tor_torrcdir:/usr/local/etc/tor/'
    ports:
      - '49392:49392'
  monerod_wallet:
    restart: unless-stopped
    container_name: btcpayserver_monero_wallet
    image: btcpayserver/monero:0.18.3.3
    entrypoint: monero-wallet-rpc --rpc-bind-ip=0.0.0.0 --disable-rpc-login --confirm-external-bind --rpc-bind-port=18082 --non-interactive --trusted-daemon  --daemon-address=xmr-node.cakewallet.com:18081 --wallet-file=/wallet/wallet --password-file /wallet/password --tx-notify="/bin/sh ./scripts/notifier.sh  -X GET http://btcpayserver:49392/monerolikedaemoncallback/tx?cryptoCode=xmr&hash=%s"
    expose:
      - '18082'
    ports:
      - 18082:18082
    volumes:
      - 'xmr_wallet:/wallet'

  nbxplorer:
    restart: unless-stopped
    container_name: generated_nbxplorer_1
    image: nicolasdorier/nbxplorer:2.5.2
    expose:
      - '32838'
    environment:
      NBXPLORER_NETWORK: ${NBITCOIN_NETWORK:-mainnet}
      NBXPLORER_BIND: 0.0.0.0:32838
      NBXPLORER_TRIMEVENTS: 10000
      NBXPLORER_SIGNALFILESDIR: /datadir
      NBXPLORER_POSTGRES: User ID=postgres;Host=btcpay-postgres;Port=5432;Application Name=nbxplorer;MaxPoolSize=20;Database=nbxplorer${NBITCOIN_NETWORK:-mainnet}
      NBXPLORER_AUTOMIGRATE: 1
      NBXPLORER_NOMIGRATEEVTS: 1
      NBXPLORER_DELETEAFTERMIGRATION: 1
    links:
      - btcpay-postgres
    volumes:
      - 'nbxplorer_datadir:/datadir'

  btcpay-postgres:
    restart: unless-stopped
    container_name: generated_postgres_1
    shm_size: 256mb
    image: btcpayserver/postgres:13.13
    command: ['-c', 'random_page_cost=1.0', '-c', 'shared_preload_libraries=pg_stat_statements']
    environment:
      POSTGRES_HOST_AUTH_METHOD: trust
    volumes:
      - 'btcpay_postgres_datadir:/var/lib/postgresql/data'

  magic-postgres:
    image: postgres:16-alpine
    container_name: magic-postgres
    restart: unless-stopped
    ports:
      - 5432:5432
    environment:
      POSTGRES_USER: magic
      POSTGRES_DB: magic
      POSTGRES_PASSWORD: magic
    volumes:
      - 'magic_postgres_data:/var/lib/postgresql/data'

  keycloak:
    image: quay.io/keycloak/keycloak:25.0.6
    container_name: magic-keycloak
    restart: unless-stopped
    command: start-dev
    ports:
      - 8080:8080
    environment:
      KEYCLOAK_ADMIN: admin
      KEYCLOAK_ADMIN_PASSWORD: admin

  campaign-site:
    image: node:20-alpine
    container_name: magic-campaign-site
    restart: unless-stopped
    working_dir: /app
    command: npm run dev
    ports:
      - 3000:3000
    volumes:
      - '.:/app'

volumes:
  btcpay_datadir:
  btcpay_pluginsdir:
  xmr_wallet:
  xmr_data:
  tor_datadir:
  tor_torrcdir:
  tor_servicesdir:
  nbxplorer_datadir:
  btcpay_postgres_datadir:
  magic_postgres_data:
