LibreChat icon indicating copy to clipboard operation
LibreChat copied to clipboard

Enhancement: Portainer compatible docker-compose

Open mist0706 opened this issue 1 year ago • 5 comments

Contact Details

[email protected]

What features would you like to see added?

The ability to easily deploy and manage an instance through portainer

More details

The use of the env file hard coded into the software causes the deployment to fail. Portainer has the ability to import .env files and then render them during deployment. This can be done by substituting "env_file: .env" with "env_file: stack.env". Unfortunately the .env file is also used as a volume and i don't believe there is a way to do that kind of substitution in portainer.

It also seems like many of the docker-compose volumes are not included in the image itself and thus the entire repo needs to be downloaded in order for the application to run

Which components are impacted by your request?

General

Pictures

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

mist0706 avatar Dec 04 '23 13:12 mist0706

env file hard coded into the software

are you referring to the dockerfile? is it possible for you to comment out touch .env && \ and see if it impacts your use case?

Have you seen this guide? I know podman is not equal to portainer but maybe there's some lucidation in this guide (I use neither)

https://docs.librechat.ai/install/container_install.html

It also seems like many of the docker-compose volumes are not included in the image itself and thus the entire repo needs to be downloaded in order for the application to run

this is true. I'll gladly take any suggestions and help to writing a new dockerfile that does this.

danny-avila avatar Dec 04 '23 13:12 danny-avila

you should also see if you encounter any of these issues with this image: https://github.com/users/danny-avila/packages/container/package/librechat-dev-api which uses the alternate Dockerfile.multi and deploy-compose.yml

danny-avila avatar Dec 04 '23 13:12 danny-avila

I just checked your dockerfile and it already does "COPY . /app" which means the volumes SHOULD be superflous, though i haven't tested this theory yet. I will try your suggestion on the alternate deploy-compose and potentially submit a PR for a Dockerfile/compose adjustment if necessary

mist0706 avatar Dec 04 '23 13:12 mist0706

I just checked your dockerfile and it already does "COPY . /app" which means the volumes SHOULD be superflous, though i haven't tested this theory yet. I will try your suggestion on the alternate deploy-compose and potentially submit a PR for a Dockerfile/compose adjustment if necessary

thank you 🙏

danny-avila avatar Dec 04 '23 13:12 danny-avila

The repo is actually not necessary at all, nor is the .env file. You can just put everything in the compose file itself. Secrets can go into the Portainer env and be referenced in the Compose file.

pikaro avatar Dec 21 '23 19:12 pikaro

I think the recent update in #1415 closes this

danny-avila avatar Jan 12 '24 23:01 danny-avila

I'll drop my portainer compose file here since it might be useful for some:

version: "3.8"
services:
  api:
    image: ghcr.io/danny-avila/librechat-dev:latest
    container_name: LibreChat
    ports:
      - 3080:3080
    restart: always
    env_file:
      - stack.env
    volumes:
      - /LibreChat/images:/app/client/public/images
  meilisearch:
    container_name: Meilisearch
    image: getmeili/meilisearch:v1.5.1
    restart: always
    env_file:
      - stack.env
    volumes:
      - /LibreChat/meili_data_v1.5:/meili_data

I used an online database (see: online db ) All variables are in the portainer env. I imported the .env.example and customized it (I updated the MONGO_URI with my online db)

fuegovic avatar Jan 12 '24 23:01 fuegovic

Thanks @fuegovic , I have success with this portainer compose file below with mongodb in docker (using v4 as my cpu does not support avx) , copied paste most .env.example variables into the advance mode for Environment variables field.

# review .env at https://github.com/danny-avila/LibreChat/blob/main/.env.example
version: "3.8"
services:
  api:
    image: librechat/librechat-dev:latest
    container_name: LibreChat
    ports:
      - 3080:3080
    restart: always
    env_file:
      - stack.env
    environment:
      - HOST=0.0.0.0
      - NODE_ENV=production
      - MONGO_URI=mongodb://mongodb:27017/LibreChat
      - MEILI_HOST=http://meilisearch:7700
   # https://hub.docker.com/u/librechat - uses single image from DockerFile 
    volumes:
      - /LibreChat/images:/app/client/public/images
  meilisearch:
    container_name: chat-meilisearch
    image: getmeili/meilisearch:v1.5.1
    restart: always
    env_file:
      - stack.env
    environment:
      - MEILI_HOST=http://meilisearch:7700
      - MEILI_NO_ANALYTICS=true
    volumes:
      - /LibreChat/meili_data_v1.5:/meili_data
  mongodb:
    container_name: chat-mongodb
    # ports:  # Uncomment this to access mongodb from outside docker, not safe in deployment
    #   - 27018:27017
    # Modify to mongo:4.4.18 for missing AVX CPU
    image: mongo:4.4.18
    restart: always
    volumes:
      - /LibreChat/data-node:/data/db
    command: mongod --noauth

jereloh avatar Mar 06 '24 15:03 jereloh

I was able to successfully deploy in portainer as per @jereloh - but how can I customize librechat.yml within portainer? Doesnt seem portainer supports the docker-compose.overide.yml

Any suggestions?

kempec110 avatar May 06 '24 03:05 kempec110

@kempec110 I personally use a remote yaml file I host on github You can look at my repo for examples and instructions: https://github.com/fuegovic/lc-config-yaml

fuegovic avatar May 06 '24 03:05 fuegovic

Thanks @fuegovic , I have success with this portainer compose file below with mongodb in docker (using v4 as my cpu does not support avx) , copied paste most .env.example variables into the advance mode for Environment variables field.

# review .env at https://github.com/danny-avila/LibreChat/blob/main/.env.example
version: "3.8"
services:
  api:
    image: librechat/librechat-dev:latest
    container_name: LibreChat
    ports:
      - 3080:3080
    restart: always
    env_file:
      - stack.env
    environment:
      - HOST=0.0.0.0
      - NODE_ENV=production
      - MONGO_URI=mongodb://mongodb:27017/LibreChat
      - MEILI_HOST=http://meilisearch:7700
   # https://hub.docker.com/u/librechat - uses single image from DockerFile 
    volumes:
      - /LibreChat/images:/app/client/public/images
  meilisearch:
    container_name: chat-meilisearch
    image: getmeili/meilisearch:v1.5.1
    restart: always
    env_file:
      - stack.env
    environment:
      - MEILI_HOST=http://meilisearch:7700
      - MEILI_NO_ANALYTICS=true
    volumes:
      - /LibreChat/meili_data_v1.5:/meili_data
  mongodb:
    container_name: chat-mongodb
    # ports:  # Uncomment this to access mongodb from outside docker, not safe in deployment
    #   - 27018:27017
    # Modify to mongo:4.4.18 for missing AVX CPU
    image: mongo:4.4.18
    restart: always
    volumes:
      - /LibreChat/data-node:/data/db
    command: mongod --noauth

Just want to update a new config that i used with portainer with the latest 0.7.2 librechat so that i can use chatgpt-4o :)

# This file is modified from https://github.com/danny-avila/LibreChat/blob/main/docker-compose.yml
# Rename .env to stack.env and review https://github.com/danny-avila/LibreChat/blob/main/stack.env.example
# Remove cloudflare if not required

version: "3.8"
services:
  api:
    container_name: LibreChat
    ports:
      - "${PORT}:${PORT}" 
    depends_on:
      - mongodb
      - rag_api
    image: ghcr.io/danny-avila/librechat-dev:latest
    restart: always
    user: "${UID}:${GID}"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    environment:
      - HOST=0.0.0.0
      - MONGO_URI=mongodb://mongodb:27017/LibreChat
      - MEILI_HOST=http://meilisearch:7700
      - RAG_PORT=${RAG_PORT:-8000}
      - RAG_API_URL=http://rag_api:${RAG_PORT:-8000}
    env_file:
      - stack.env
    volumes:
      # - type: bind
      #   source: .env
      #   target: /app/.env
      - ./images:/app/client/public/images
      - ./logs:/app/api/logs
  mongodb:
    container_name: chat-mongodb
     # Modify to mongo:4.4.X for compatiblity with missing AVX CPU
    image: mongo:4.4.29
    restart: always
    user: "${UID}:${GID}"
    volumes:
      - ./data-node:/data/db
    command: mongod --noauth
  meilisearch:
    container_name: chat-meilisearch
    image: getmeili/meilisearch:v1.7.3
    restart: always
    user: "${UID}:${GID}"
    environment:
      - MEILI_HOST=http://meilisearch:7700
      - MEILI_NO_ANALYTICS=true
    volumes:
      - ./meili_data_v1.7:/meili_data
  vectordb:
    container_name: vectordb
    image: ankane/pgvector:latest
    environment:
      POSTGRES_DB: mydatabase
      POSTGRES_USER: myuser
      POSTGRES_PASSWORD: mypassword
    restart: always
    volumes:
      - pgdata2:/var/lib/postgresql/data
  rag_api:
    container_name: rag_api
    image: ghcr.io/danny-avila/librechat-rag-api-dev-lite:latest
    environment:
      - DB_HOST=vectordb
      - RAG_PORT=${RAG_PORT:-8000}
    restart: always
    depends_on:
      - vectordb
    env_file:
      - stack.env
  
  # Cloudflared if required
  cloudflared:
    image: wisdomsky/cloudflared-web:latest
    restart: unless-stopped
    network_mode: host
    environment:
      WEBUI_PORT: 1001
      
volumes:
  pgdata2:

jereloh avatar May 15 '24 06:05 jereloh