services:
  generate-openapi-spec:
    image: tobiko-api
    container_name: generate-openapi-spec
    working_dir: /sqlmesh
    build:
      context: ..
      dockerfile: web/Dockerfile.api
    command: python web/server/openapi.py
    volumes:
      - ..:/sqlmesh

  app:
    image: tobiko-app
    container_name: tobiko-app
    build:
      context: ..
      dockerfile: web/Dockerfile.app
    command: pnpm run dev --host 0.0.0.0 --port 8001
    working_dir: /app/web/client
    ports:
      - 8001:8001
    volumes:
      - ../web/client:/app/web/client
      - /app/web/client/node_modules
    tty: true
    networks:
      - tobiko-development
    depends_on:
      - generate-openapi-spec

  api:
    image: tobiko-api
    container_name: tobiko-api
    working_dir: /home
    build:
      context: ..
      dockerfile: web/Dockerfile.api
    command:
      python -m uvicorn web.server.app:app --host 0.0.0.0 --port 8000 --reload
      --reload-dir /sqlmesh/web/server --reload-dir /sqlmesh/sqlmesh
      --timeout-keep-alive 300 --timeout-graceful-shutdown 1
    ports:
      - 8000:8000
    volumes:
      - ..:/sqlmesh
    networks:
      - tobiko-development
    environment:
      - PYTHONPATH=/sqlmesh
      - PROJECT_PATH=${PROJECT_PATH:-/sqlmesh/examples/sushi}
      - UI_MODE=ide

networks:
  tobiko-development:
    driver: bridge
