# Compose template extracted by `node-app-build dev --daemon docker`
# (plan 457 phase C+). Bundled into the binary at compile time via
# include_str! and written to $XDG_CACHE_HOME/node-app-build/compose/.
#
# Single service. Lightning sync runs in the background via the ldk-node
# builtin app; it will not sync without an esplora server (expected in
# a no-external-deps dev environment). App sideloading, IPC, and capability
# routing all work independently of Lightning sync.
#
# The host volume mounts NODE_DEV_APPS_DIR so the daemon's inotify
# watcher inside the container picks up artifacts that the CLI writes
# from the host. macOS volume sync has ~1s latency through the Docker
# VM — acceptable given the watcher's 500ms quiet window.

services:
  node-server:
    image: ghcr.io/econ-v1/node-server:dev
    container_name: node-app-build-dev-daemon
    restart: unless-stopped
    environment:
      # Required by Config::load
      LDK_NETWORK: regtest
      DATA_DIR_PATH: /var/lib/node
      APPS_INSTALL_DIR: /usr/lib/node/apps
      LDK_LISTENING_ADDRESS: "0.0.0.0:9735"
      SIGNER_SEED_PATH: /var/lib/node/signer_seed.hex
      SERVER_ADDRESS: "0.0.0.0:3001"
      RUST_LOG: "info,node_server=debug,node_server::apps=debug"
      # IPC socket path — must match /run/node volume mount below
      NODE_IPC_SOCKET: /run/node/control.sock
      # Dev-apps directory — must match /dev-apps volume mount below
      NODE_DEV_APPS_DIR: /dev-apps
      # Disable features not needed for the inner dev loop
      DEVELOPMENT_MODE: "true"
      ACME_ENABLED: "false"
      RATHOLE_ENABLED: "false"
      STATIC_DIR_PATH: ""
      DATABASE_URL: sqlite:///var/lib/node/dev.db
      # Disable inotify if you hit cross-platform issues — the IPC
      # dev_load path still works.
      NODE_INOTIFY_DISABLE: "0"
    ports:
      # HTTP API exposed on host for frontend dev server (yarn dev) and
      # for `node-app-build dev` smoke checks via curl.
      - "3001:3001"
    volumes:
      # Dev-apps mount: the CLI writes here from the host; the daemon
      # reads from here inside the container.
      - "${NODE_DEV_APPS_DIR:-./dev-apps}:/dev-apps:cached"
      # IPC socket dir: the CLI talks to the daemon over this Unix socket.
      # HOST path controlled by NODE_APP_BUILD_SOCK_DIR (set by the CLI).
      - "${NODE_APP_BUILD_SOCK_DIR:-./socket}:/run/node:cached"
      # Persist daemon SQLite + LDK data across container restarts.
      - "${NODE_APP_BUILD_DATA:-./data}:/var/lib/node"
    healthcheck:
      test: ["CMD", "curl", "-fsS", "http://localhost:3001/api/v1/system/health"]
      interval: 5s
      timeout: 2s
      retries: 24  # ~2min total
      start_period: 10s
