# Docker Compose for building WASM modules
# Usage: docker compose -f docker-compose.wasm.yml up --build

services:
  # ==========================================================================
  # WASM Builder - synor-crypto-wasm
  # ==========================================================================
  wasm-builder:
    build:
      context: .
      dockerfile: Dockerfile.wasm
    container_name: synor-wasm-builder
    volumes:
      # Output built WASM to web wallet directory
      - ./apps/web/src/wasm:/dest
    command: >
      sh -c '
        echo "Copying WASM artifacts to web wallet..."
        cp -r /wasm-output/pkg/* /dest/
        echo "WASM build complete!"
        ls -la /dest/
      '

  # ==========================================================================
  # Web Wallet Development Server (with WASM)
  # ==========================================================================
  web-wallet:
    build:
      context: ./apps/web
      dockerfile: Dockerfile.dev
    container_name: synor-web-wallet
    ports:
      - "5173:5173"  # Vite dev server
    volumes:
      - ./apps/web/src:/app/src
      - ./apps/web/public:/app/public
    environment:
      - VITE_RPC_URL=http://localhost:17110
      - VITE_WS_URL=ws://localhost:17111
      - VITE_NETWORK=testnet
    depends_on:
      wasm-builder:
        condition: service_completed_successfully
    profiles:
      - dev

networks:
  default:
    name: synor-build
