version: '3.9'

services:
  devcontainer:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - ../:/workspace:cached
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - SURREAL_URL=ws://surrealdb:8000
      - SURREAL_USER=root
      - SURREAL_PASS=root
      - NATS_URL=nats://nats:4222
      - OLLAMA_URL=http://ollama:11434
      - LOG_LEVEL=debug
      - RUST_LOG=vapora=debug,info
    command: sleep infinity
    depends_on:
      - surrealdb
      - nats
      - ollama
    networks:
      - vapora-network

  surrealdb:
    image: surrealdb/surrealdb:v2.3
    command: >
      start
      --log trace
      --user root
      --pass root
      memory
    ports:
      - "8000:8000"
    networks:
      - vapora-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
      interval: 10s
      timeout: 5s
      retries: 5

  nats:
    image: nats:2.10-alpine
    command: >
      -js
      -sd /data
      --http_port 8222
    ports:
      - "4222:4222"
      - "8222:8222"
    volumes:
      - nats-data:/data
    networks:
      - vapora-network
    healthcheck:
      test: ["CMD", "nats", "server", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

  ollama:
    image: ollama/ollama:latest
    ports:
      - "11434:11434"
    volumes:
      - ollama-data:/root/.ollama
    environment:
      - OLLAMA_HOST=0.0.0.0:11434
    networks:
      - vapora-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:11434/api/tags"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

volumes:
  nats-data:
  ollama-data:

networks:
  vapora-network:
    driver: bridge
