onyx icon indicating copy to clipboard operation
onyx copied to clipboard

How to install it with Traefik?

Open Daniel199438 opened this issue 1 year ago • 0 comments

I have tried it several times, but I didnt get it to work. I always get a '502 Bad gateway' error.

Thats the modified docker-compose.prod.yml file:

version: '3'
services:
  api_server:
    image: danswer/danswer-backend:latest
    build:
      context: ../../backend
      dockerfile: Dockerfile
    command: >
      /bin/sh -c "alembic upgrade head &&
      echo \"Starting Danswer Api Server\" &&
      uvicorn danswer.main:app --host 0.0.0.0 --port 8089"
    depends_on:
      - relational_db
      - index
    restart: always
    ports:
      - "8089:8080"     
    networks:
      - proxy
    env_file:
      - .env
    environment:
      - POSTGRES_HOST=relational_db
      - VESPA_HOST=index
    volumes:
      - local_dynamic_storage:/home/storage
      - file_connector_tmp_storage:/home/file_connector_storage
      - model_cache_torch:/root/.cache/torch/
      - model_cache_nltk:/root/nltk_data/
      - model_cache_huggingface:/root/.cache/huggingface/
  background:
    image: danswer/danswer-backend:latest
    build:
      context: ../../backend
      dockerfile: Dockerfile
    command: /usr/bin/supervisord
    depends_on:
      - relational_db
      - index
    restart: always
    networks:
      - proxy
    env_file:
      - .env
    environment:
      - POSTGRES_HOST=relational_db
      - VESPA_HOST=index
    volumes:
      - local_dynamic_storage:/home/storage
      - file_connector_tmp_storage:/home/file_connector_storage
      - model_cache_torch:/root/.cache/torch/
      - model_cache_nltk:/root/nltk_data/
      - model_cache_huggingface:/root/.cache/huggingface/
  web_server:
    image: danswer/danswer-web-server:latest
    build:
      context: ../../web
      dockerfile: Dockerfile
    depends_on:
      - api_server
    networks:
      - proxy
    restart: always
    env_file:
      - .env
    environment:
      - INTERNAL_URL=http://api_server:8089
  relational_db:
    image: postgres:15.2-alpine
    restart: always
    networks:
      - proxy
    # POSTGRES_USER and POSTGRES_PASSWORD should be set in .env file
    env_file:
      - .env
    volumes:
      - db_volume:/var/lib/postgresql/data
  index:
    image: vespaengine/vespa:8
    restart: always
    networks:
      - proxy
    ports:
      - "19071:19071"
      - "8081:8081"
    volumes:
      - vespa_volume:/opt/vespa/var    
  nginx:
    image: nginx:1.23.4-alpine
    restart: always
    # nginx will immediately crash with `nginx: [emerg] host not found in upstream`
    # if api_server / web_server are not up 
    depends_on:
      - api_server
      - web_server
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=proxy"
      - "traefik.http.routers.danswer.entrypoints=websecure"
      - "traefik.http.routers.danswer.rule=Host(`mydomain`)"
      - "traefik.http.services.danswer.loadbalancer.server.port=80"
    networks:
      - proxy
    volumes:
      - ../data/nginx:/etc/nginx/conf.d

volumes:
  local_dynamic_storage:
  file_connector_tmp_storage:  # used to store files uploaded by the user temporarily while we are indexing them
  db_volume:
  vespa_volume:
  model_cache_torch:
  model_cache_nltk:
  model_cache_huggingface:
  
networks:
  proxy:
    external: true

Daniel199438 avatar Sep 18 '23 12:09 Daniel199438