services:
  es:
    image: elasticsearch:9.2.1
    container_name: aurak-es
    environment:
      - discovery.type=single-node
      - xpack.security.enabled=false
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ports:
      - "9200:9200"
    volumes:
      - es-data:/usr/share/elasticsearch/data
    networks:
      - aurak-network
  #    restart: unless-stopped

  tika:
    image: apache/tika:latest
    container_name: aurak-tika
    ports:
      - "9998:9998"
    networks:
      - aurak-network
    restart: unless-stopped

  libreoffice:
    build:
      context: ./libreoffice-server
      dockerfile: Dockerfile
    container_name: aurak-libreoffice
    ports:
      - "8100:8100"
    volumes:
      - ./uploads:/app/uploads
      - ./temp:/temp
    networks:
      - aurak-network
    restart: unless-stopped
  # ollama:
  #   image: ollama/ollama:latest
  #   container_name: aurak-ollama
  #   ports:
  #     - "11434:11434"
  #   environment:
  #     - OLLAMA_CPU_ONLY=1
  #   volumes:
  #     - ollama-data:/root/.ollama
  #   networks:
  #     - aurak-network
  #   restart: unless-stopped
  #   entrypoint: ["/bin/sh", "-c"]
  #   command: >
  #     "ollama serve & 
  #     sleep 10 && 
  #     ollama pull qwen2.5:3b && 
  #     ollama pull nomic-embed-text:latest && 
  #     ollama pull llava-phi3:3.8b && 
  #     echo 'All models pulled successfully!' && 
  #     wait"

  server:
    build:
      context: ./server
      dockerfile: Dockerfile
    container_name: aurak-server
    environment:
      - NODE_ENV=production
      - NODE_OPTIONS=--max-old-space-size=8192
      - PORT=3001
      - DATABASE_PATH=/app/data/metadata.db
      - ELASTICSEARCH_HOST=http://es:9200
      - TIKA_HOST=http://tika:9998
      - LIBREOFFICE_URL=http://libreoffice:8100
      - JWT_SECRET=13405a7d-742a-41f5-8b34-012735acffea
      - UPLOAD_FILE_PATH=/app/uploads
      - DEFAULT_VECTOR_DIMENSIONS=2048
      - TEMP_DIR=/app/temp
      - CHUNK_BATCH_SIZE=50
    volumes:
      - ./data:/app/data
      - ./uploads:/app/uploads
      - ./temp:/app/temp
    depends_on:
      - es
      - tika
      - libreoffice
    #    restart: unless-stopped
    networks:
      - aurak-network

  web:
    build:
      context: .
      dockerfile: ./web/Dockerfile
      args:
        - VITE_API_BASE_URL=/api
    container_name: aurak-web
    depends_on:
      - server
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
    networks:
      - aurak-network

networks:
  aurak-network:
    driver: bridge

volumes:
  es-data:
    driver: local
  ollama-data:
    driver: local
  aurak-data:
    driver: local
