version: "3.9"
networks:
  llm_network:
    driver: bridge
services:
  #nginx:
  #  container_name: ${APP_PREFIX}_reverseproxy
  #  image: nginxinc/nginx-unprivileged #:1.25-alpine
  #  restart: always
  #  ports:
  #    - "81:8080"
  #  volumes:
  #    - type: bind
  #      source: ./nginx.conf
  #      target: /etc/nginx/nginx.conf
  #  networks:
  #    - llm_network

  minio:
    container_name: ${APP_PREFIX}_minio
    image: minio/minio
    ports:
      - "29000:9000"
      - "29001:9001"
    networks:
      - llm_network
    volumes:
      - "minio_data:/data"
    environment:
      - MINIO_ROOT_USER=root
      - MINIO_ROOT_PASSWORD=rootrootroot
      - MINIO_DEFAULT_BUCKETS=defaultbucket
    command: server --console-address ":29001" /data

  neo4j:
    container_name: ${APP_PREFIX}_neo4j
    image: neo4j
    #image: neo4j:3.5
    #image: neo4j:4.1
    restart: unless-stopped
    ports:
      - 7474:7474
      - 7687:7687
    volumes:
      - ./conf:/conf
      - ./data:/data
      - ./import:/import
      - ./logs:/logs
      - ./plugins:/plugins
    environment: 
      - NEO4J_AUTH=neo4j/your_password

      # Raise memory limits
      - NEO4J_server_memory_pagecache_size=512M
      - NEO4J_server_memory_heap_max__size=512M

      - dbms.usage_report.enabled=false


  elasticsearch:
    container_name: ${APP_PREFIX}_elasticsearch
    image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
    restart: always
    mem_limit: 4024m
    ports:
      - "9200:9200"
    environment:
      - discovery.type=single-node
      - logger.level=ERROR
      - bootstrap.memory_lock=true # Disable JVM heap memory swapping
      - xpack.security.enabled=false
      - xpack.security.http.ssl.enabled=false

    volumes:
      - esdata:/usr/share/elasticsearch/data
    ulimits:
      memlock:
        soft: -1 # Set memlock to unlimited (no soft or hard limit)
        hard: -1
      nofile:
        soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
        hard: 65536
    networks:
      - llm_network

  ollama:
    container_name: ${APP_PREFIX}_ollama
    image: ollama/ollama:latest
    restart: always
    ports:
      - "11434:11434"
    environment:
      - OLLAMA_NUM_PARALLEL=4
      - OLLAMA_MAX_LOADED_MODELS=4

    volumes:
      - ..:/code
      - ../ollama/ollama:/root/.ollama
    networks:
      - llm_network
    devices:
      #- /dev/dri/renderD128:/dev/dri/renderD128
      #- /dev/fdk
      - /dev/dri








  #ollama-webui:
  #  container_name: ${APP_PREFIX}_ollama-webui
  #  image: ghcr.io/ollama-webui/ollama-webui:main
  #  volumes:
  #    - ../ollama/ollama-webui:/app/backend/data
  #  depends_on:
  #    - ollama
  #  ports:
  #    - 8888:8080
  #  environment:
  #    - "/ollama/api=http://ollama:11434/api"
  #  extra_hosts:
  #   - host.docker.internal:host-gateway
  #  restart: unless-stopped
  #  networks:
  #    - llm_network

  #frontend:
  #  container_name: ${APP_PREFIX}_frontend
  #  image: ${APP_PREFIX}-vue-frontend
  #  restart: always
  #  ports:
  #    - "3000:3000"
  #  build: ./frontend

  backend:
    container_name: ${APP_PREFIX}_backend
    image: registry.tobiasweise.dev/${APP_PREFIX}-python-backend
    restart: always
    ports:
      - "5000:5000"
    env_file:
      - .env
    environment:
      - LOG_LEVEL=ERROR
      - BOT_ROOT_PATH=/
      - ELASTIC_URI=http://elasticsearch:9200
      - OLLAMA_URI=http://ollama:11434

    build: ../backend
    #build:
    #  context: ../backend
    #  dockerfile: ../backend/Deb_Dockerfile

    networks:
      - llm_network
    depends_on:
      - elasticsearch
      - ollama
      - minio

volumes:
  esdata:
    driver: local
  filedata:
  minio_data:
    driver: local
