feat: docker-compose deployment file (#706)

* 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

* chore(deploy-compose.yml): update env_file path to ../../.env

* chore(deploy-compose.yml): update image name to librechat_deploy
chore(deploy-compose.yml): update build context to ../../

* 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.

* refactor(nginx.conf): reformat nginx.conf for better readability and maintainability

* chore(nginx.conf): add worker_connections configuration to events block
chore(nginx.conf): add listen configuration to server block

* chore(deploy-compose.yml): update nginx container ports configuration
feat(deploy-compose.yml): add support for HTTPS by exposing port 443

* docs(dev/README.md): add instructions for deploying with deploy-compose.yml

* docs(dev/README.md): update instructions for deploying with deploy-compose.yml
This commit is contained in:
Danny Avila 2023-07-26 12:57:26 -04:00 committed by GitHub
parent b6028a3434
commit f4f1199a55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 89 additions and 12 deletions

View file

@ -1,15 +1,19 @@
events {
worker_connections 1024;
}
http {
server { server {
listen 80; listen 80;
server_name localhost; server_name localhost;
location /api { location /api {
# Proxy requests to the API service
proxy_pass http://api:3080/api; proxy_pass http://api:3080/api;
} }
location / { location / {
# Serve your React app
root /usr/share/nginx/html; root /usr/share/nginx/html;
try_files $uri $uri/ /index.html; try_files $uri $uri/ /index.html;
} }
} }
}

View file

@ -15,3 +15,11 @@ This directory contains files used for developer work
- This requires you use a MongoDB Atlas connection string for the `MONGO_URI` env var - 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. - 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. - 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 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, as they are already setup for you.

View file

@ -0,0 +1,65 @@
version: "3.4"
services:
client:
image: nginx:latest
restart: always
ports:
- 80:80
- 443:443
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: ghcr.io/danny-avila/librechat:latest
# image: librechat_deploy
# 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