version: "3"
services:
  server:
    image: ollama/ollama
    container_name: ollama
    ports:
      - 11434:11434
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - OLLAMA_ORIGINS=http://192.168.178.43:*,https://llm.ghoscht.com
      - OLLAMA_HOST=0.0.0.0
    restart: always
    volumes:
      - ollama_data:/root/.ollama
    networks:
      traefik_net:
    dns:
      - 1.1.1.1
    labels:
      - traefik.enable=true
      - traefik.http.routers.ollama.entrypoints=websecure
      - traefik.http.routers.ollama.rule=Host(`ollama.ghoscht.com`)
      - traefik.http.services.ollama.loadbalancer.server.port=11434
      - traefik.docker.network=traefik-net
      - traefik.http.routers.ollama.tls=true
      - traefik.http.routers.ollama.tls.certresolver=lencrypt
      - traefik.http.middlewares.cors.headers.customResponseHeaders.Access-Control-Allow-Origin=https://llm.ghoscht.com
      - "traefik.http.middlewares.cors.headers.accesscontrolallowmethods=*"
      - "traefik.http.middlewares.cors.headers.accesscontrolalloworiginlist=*"
      - "traefik.http.middlewares.cors.headers.accesscontrolmaxage=100"
      - "traefik.http.middlewares.cors.headers.addvaryheader=true"
      - "traefik.http.middlewares.cors.headers.accesscontrolallowheaders=*"
      - traefik.http.routers.ollama.middlewares=cors
  webui:
    image: ollamawebui/ollama-webui
    container_name: ollama-webui
    restart: always
    environment:
      - PUBLIC_API_BASE_URL=https://ollama.ghoscht.com/api
    networks:
      traefik_net:
    labels:
      - traefik.enable=true
      - traefik.http.routers.ollama-webui.entrypoints=websecure
      - traefik.http.routers.ollama-webui.rule=Host(`llm.ghoscht.com`)
      - traefik.http.services.ollama-webui.loadbalancer.server.port=8080
      - traefik.docker.network=traefik-net
      - traefik.http.routers.ollama-webui.tls=true
      - traefik.http.routers.ollama-webui.tls.certresolver=lencrypt
networks:
  traefik_net:
    name: traefik-net
    external: true
volumes:
  ollama_data:
    name: ollama_data