From 195454c8a01e366fc01047bc91792636d9682dfd Mon Sep 17 00:00:00 2001 From: Daniel Avila Date: Sat, 22 Jul 2023 19:15:50 -0400 Subject: [PATCH 1/9] feat(deploy-compose.yml): add docker-compose file for development deployment A new docker-compose file has been added for development deployment. This file defines the services required for running the application in a development environment. The services include a client service running nginx, an api service running the LibreChat application, a mongodb service for the database, and a meilisearch service for search functionality. The client service is configured to use the latest version of the nginx image, with port 3080 mapped to port 80. It also mounts the nginx.conf file and the client's node_modules directory. The api service is named LibreChat and is built from the librechat image. It exposes port 9000 and depends on the mongodb service. It also mounts the api directory, the .env files, and the client's node_modules directory. The mongodb service is named chat-mongodb and uses the mongo image. It exposes port 27018 and mounts the data-node directory for data storage --- docs/dev/deploy-compose.yml | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 docs/dev/deploy-compose.yml diff --git a/docs/dev/deploy-compose.yml b/docs/dev/deploy-compose.yml new file mode 100644 index 00000000000..5623af8c6d2 --- /dev/null +++ b/docs/dev/deploy-compose.yml @@ -0,0 +1,63 @@ +version: "3.4" + +services: + client: + image: nginx:latest + restart: always + ports: + - 3080:80 + volumes: + - ../../client/nginx.conf:/etc/nginx/nginx.conf + - /app/client/node_modules + depends_on: + - api + api: + container_name: LibreChat + ports: + - 9000:3080 + depends_on: + - mongodb + image: librechat + build: + context: . + target: node + restart: always + extra_hosts: + - "host.docker.internal:host-gateway" + env_file: + - ../../.env + environment: + - HOST=0.0.0.0 + - MONGO_URI=mongodb://mongodb:27017/LibreChat + - MEILI_HOST=http://meilisearch:7700 + - MEILI_HTTP_ADDR=meilisearch:7700 + volumes: + - /app/client/node_modules + - ../../api:/app/api + - ../../.env:/app/.env + - ../../.env.development:/app/.env.development + - ../../.env.production:/app/.env.production + - /app/api/node_modules + - ../../images:/app/client/public/images + mongodb: + container_name: chat-mongodb + ports: + - 27018:27017 + image: mongo + restart: always + volumes: + - ./data-node:/data/db + command: mongod --noauth + meilisearch: + container_name: chat-meilisearch + image: getmeili/meilisearch:v1.0 + ports: + - 7700:7700 + env_file: + - .env + environment: + - MEILI_HOST=http://meilisearch:7700 + - MEILI_HTTP_ADDR=meilisearch:7700 + - MEILI_NO_ANALYTICS=true + volumes: + - ./meili_data:/meili_data From 805784c2e30de9d3e6cc88d29f56974d6cc6c6fa Mon Sep 17 00:00:00 2001 From: Daniel Avila Date: Sat, 22 Jul 2023 19:40:53 -0400 Subject: [PATCH 2/9] chore(deploy-compose.yml): update env_file path to ../../.env --- docs/dev/deploy-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/deploy-compose.yml b/docs/dev/deploy-compose.yml index 5623af8c6d2..33e254db40a 100644 --- a/docs/dev/deploy-compose.yml +++ b/docs/dev/deploy-compose.yml @@ -54,7 +54,7 @@ services: ports: - 7700:7700 env_file: - - .env + - ../../.env environment: - MEILI_HOST=http://meilisearch:7700 - MEILI_HTTP_ADDR=meilisearch:7700 From 8d79fd1f5851d1abc679439c350706a8dc53c86c Mon Sep 17 00:00:00 2001 From: Daniel Avila Date: Sat, 22 Jul 2023 19:43:29 -0400 Subject: [PATCH 3/9] chore(deploy-compose.yml): update image name to librechat_deploy chore(deploy-compose.yml): update build context to ../../ --- docs/dev/deploy-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/dev/deploy-compose.yml b/docs/dev/deploy-compose.yml index 33e254db40a..b5266c08166 100644 --- a/docs/dev/deploy-compose.yml +++ b/docs/dev/deploy-compose.yml @@ -17,9 +17,9 @@ services: - 9000:3080 depends_on: - mongodb - image: librechat + image: librechat_deploy build: - context: . + context: ../../ target: node restart: always extra_hosts: From 6b3fc21aa6a41b3d43515e2537d6653968a17f30 Mon Sep 17 00:00:00 2001 From: Daniel Avila Date: Sat, 22 Jul 2023 19:51:35 -0400 Subject: [PATCH 4/9] chore(deploy-compose.yml): update image and comment out build section The image for the service has been updated to `ghcr.io/danny-avila/librechat:latest`. The build section has been commented out as it is no longer needed. --- docs/dev/deploy-compose.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/dev/deploy-compose.yml b/docs/dev/deploy-compose.yml index b5266c08166..aadcdb18a46 100644 --- a/docs/dev/deploy-compose.yml +++ b/docs/dev/deploy-compose.yml @@ -17,10 +17,11 @@ services: - 9000:3080 depends_on: - mongodb - image: librechat_deploy - build: - context: ../../ - target: node + image: ghcr.io/danny-avila/librechat:latest + # image: librechat_deploy + # build: + # context: ../../ + # target: node restart: always extra_hosts: - "host.docker.internal:host-gateway" From c84e90b88d80a610d388a967596c7120a89d858f Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Wed, 26 Jul 2023 12:12:02 -0400 Subject: [PATCH 5/9] refactor(nginx.conf): reformat nginx.conf for better readability and maintainability --- client/nginx.conf | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/client/nginx.conf b/client/nginx.conf index 96cfe345e72..2a8aba62298 100644 --- a/client/nginx.conf +++ b/client/nginx.conf @@ -1,15 +1,15 @@ -server { - listen 80; - server_name localhost; +http { + server { + listen 80; + server_name localhost; - location /api { - # Proxy requests to the API service - proxy_pass http://api:3080/api; - } + location /api { + proxy_pass http://api:3080/api; + } - location / { - # Serve your React app - root /usr/share/nginx/html; - try_files $uri $uri/ /index.html; + location / { + root /usr/share/nginx/html; + try_files $uri $uri/ /index.html; + } } } From a29a09ee5f4d1af9f5731b90da6fd86b810ed0a2 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Wed, 26 Jul 2023 12:17:54 -0400 Subject: [PATCH 6/9] chore(nginx.conf): add worker_connections configuration to events block chore(nginx.conf): add listen configuration to server block --- client/nginx.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/nginx.conf b/client/nginx.conf index 2a8aba62298..0f5204aaed6 100644 --- a/client/nginx.conf +++ b/client/nginx.conf @@ -1,3 +1,7 @@ +events { + worker_connections 1024; +} + http { server { listen 80; From 6888d0f3bae5e6558386a88f478058ffeee57661 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Wed, 26 Jul 2023 12:24:09 -0400 Subject: [PATCH 7/9] chore(deploy-compose.yml): update nginx container ports configuration feat(deploy-compose.yml): add support for HTTPS by exposing port 443 --- docs/dev/deploy-compose.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/dev/deploy-compose.yml b/docs/dev/deploy-compose.yml index aadcdb18a46..303eb5505e7 100644 --- a/docs/dev/deploy-compose.yml +++ b/docs/dev/deploy-compose.yml @@ -5,7 +5,8 @@ services: image: nginx:latest restart: always ports: - - 3080:80 + - 80:80 + - 443:443 volumes: - ../../client/nginx.conf:/etc/nginx/nginx.conf - /app/client/node_modules From 3e5c1a6adb5e5fe130fed03dc3c27f4c6185a10d Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Wed, 26 Jul 2023 12:49:59 -0400 Subject: [PATCH 8/9] docs(dev/README.md): add instructions for deploying with deploy-compose.yml --- docs/dev/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/dev/README.md b/docs/dev/README.md index 044438cbf6b..d60e691d448 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -14,4 +14,11 @@ This directory contains files used for developer work - When you don't need to build, run `docker-compose -f ./docs/dev/single-compose.yml up` - This requires you use a MongoDB Atlas connection string for the `MONGO_URI` env var - A URI string to a mongodb service accessible to your container is also possible. - - Remote Meilisearch may also be possible in the same manner, but is not tested. \ No newline at end of file + - Remote Meilisearch may also be possible in the same manner, but is not tested. +### deploy-compose.yml: +- Similar to above, but with basic configuration for deployment to a cloud provider where multi-container compose works + - Tested and working on a $6 droplet on DigitalOcean, just by visiting the server IP. + - Not a scalable solution, but ideal for quickly hosting on a remote linux server. +- From root dir of the project, run `docker-compose -f ./docs/dev/deploy-compose.yml up --build` + - When you don't need to build, run `docker-compose -f ./docs/dev/deploy-compose.yml up` +- Unlike the single-compose file, this containerizes both MongoDB and Meilisearch, so these are already setup for you. \ No newline at end of file From c28a3871884fcc43f560eb413af94c546d290e9c Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Wed, 26 Jul 2023 12:52:23 -0400 Subject: [PATCH 9/9] docs(dev/README.md): update instructions for deploying with deploy-compose.yml --- docs/dev/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/dev/README.md b/docs/dev/README.md index d60e691d448..899f415f440 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -17,8 +17,9 @@ This directory contains files used for developer work - Remote Meilisearch may also be possible in the same manner, but is not tested. ### deploy-compose.yml: - Similar to above, but with basic configuration for deployment to a cloud provider where multi-container compose works - - Tested and working on a $6 droplet on DigitalOcean, just by visiting the server IP. + - Tested and working on a $6 droplet on DigitalOcean, just by visiting the http://server-ip/9000. - Not a scalable solution, but ideal for quickly hosting on a remote linux server. + - You should adjust `server_name localhost;` to match your domain name, replacing localhost, as needed. - From root dir of the project, run `docker-compose -f ./docs/dev/deploy-compose.yml up --build` - When you don't need to build, run `docker-compose -f ./docs/dev/deploy-compose.yml up` -- Unlike the single-compose file, this containerizes both MongoDB and Meilisearch, so these are already setup for you. \ No newline at end of file +- Unlike the single-compose file, this containerizes both MongoDB and Meilisearch, as they are already setup for you. \ No newline at end of file