version: "3.8"

services:
  # Development mode
  app-dev:
    build:
      context: .
      target: development
    ports:
      - "3000:3000" # Web app (API proxied through Next.js)
    volumes:
      - .:/app
      - /app/node_modules
      - ./data:/app/data # Persist database files
    environment:
      - NODE_ENV=development
      - API_URL=http://localhost:3001 # Internal API URL for proxy
    # CLI is now the default entrypoint, can be overridden with command
    # command: pnpm dev  # Uncomment to run dev servers instead of CLI
    stdin_open: true # Keep stdin open for interactive CLI
    tty: true # Allocate a pseudo-TTY for interactive CLI

  # Production mode
  app:
    build:
      context: .
      target: production
    ports:
      - "3000:3000" # Web app (API proxied through Next.js)
    volumes:
      - ./data:/app/data # Persist database files only
    environment:
      - NODE_ENV=production
      - API_URL=http://localhost:3001 # Internal API URL for proxy
    # Runs all services (web + service) in production by default
    # Override with command to run CLI: ["node", "apps/cli/dist/index.js"]
    stdin_open: true # Keep stdin open for CLI if used
    tty: true # Allocate a pseudo-TTY for CLI if used
