From a4bc3673e7d64a5f6edd259d0667ab39ab53110b Mon Sep 17 00:00:00 2001 From: Darth Pika <103236915+darth-pika-hu@users.noreply.github.com> Date: Thu, 27 Apr 2023 11:40:25 -0700 Subject: [PATCH 1/3] Create setup.sh Added a bash script to help with installation issues. --- setup.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 setup.sh diff --git a/setup.sh b/setup.sh new file mode 100755 index 00000000..952eab35 --- /dev/null +++ b/setup.sh @@ -0,0 +1,39 @@ +#!/bin/bash +cd "$(dirname "$0")" || exit + +# Build frontend and backend images +docker build -t frontend_image ./frontend +docker build -t backend_image ./application + +# Run redis and mongo services +docker run -d --name redis -p 6379:6379 redis:6-alpine +docker run -d --name mongo -p 27017:27017 -v mongodb_data_container:/data/db mongo:6 + +# Run backend and worker services +docker run -d --name backend -p 5001:5001 \ + -v $(pwd)/application/indexes:/app/indexes \ + -v $(pwd)/application/inputs:/app/inputs \ + -v $(pwd)/application/vectors:/app/vectors \ + -e API_KEY=$OPENAI_API_KEY \ + -e EMBEDDINGS_KEY=$OPENAI_API_KEY \ + -e CELERY_BROKER_URL=redis://localhost:6379/0 \ + -e CELERY_RESULT_BACKEND=redis://localhost:6379/1 \ + -e MONGO_URI=mongodb://localhost:27017/docsgpt \ + backend_image + +docker run -d --name worker \ + -e API_KEY=$OPENAI_API_KEY \ + -e EMBEDDINGS_KEY=$OPENAI_API_KEY \ + -e CELERY_BROKER_URL=redis://localhost:6379/0 \ + -e CELERY_RESULT_BACKEND=redis://localhost:6379/1 \ + -e MONGO_URI=mongodb://localhost:27017/docsgpt \ + -e API_URL=http://localhost:5001 \ + backend_image celery -A app.celery worker -l INFO + +# Run frontend service +docker run -d --name frontend -p 5173:5173 \ + -e VITE_API_HOST=http://localhost:5001 \ + frontend_image + +# List running containers +docker ps From 1d2654b9fa1373e6019011bd00e317bff018024e Mon Sep 17 00:00:00 2001 From: Darth Pika <103236915+darth-pika-hu@users.noreply.github.com> Date: Thu, 27 Apr 2023 12:02:11 -0700 Subject: [PATCH 2/3] Update setup.sh Create required directories on the host machine if they don't exist. --- setup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setup.sh b/setup.sh index 952eab35..15fd0694 100755 --- a/setup.sh +++ b/setup.sh @@ -1,6 +1,11 @@ #!/bin/bash cd "$(dirname "$0")" || exit +# Create the required directories on the host machine if they don't exist +[ ! -d "./application/indexes" ] && mkdir -p ./application/indexes +[ ! -d "./application/inputs" ] && mkdir -p ./application/inputs +[ ! -d "./application/vectors" ] && mkdir -p ./application/vectors + # Build frontend and backend images docker build -t frontend_image ./frontend docker build -t backend_image ./application From 0beafb8391fa9b8b46db9f409d5a3dae0bd4da60 Mon Sep 17 00:00:00 2001 From: Darth Pika <103236915+darth-pika-hu@users.noreply.github.com> Date: Thu, 27 Apr 2023 12:39:03 -0700 Subject: [PATCH 3/3] Update setup.sh This script includes the necessary changes to use container linking and updated environment variables for the `backend` and `worker` containers. Make sure you have the `./frontend` and `./application` directories in the correct locations before running the script. --- setup.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/setup.sh b/setup.sh index 15fd0694..168ce87d 100755 --- a/setup.sh +++ b/setup.sh @@ -16,29 +16,30 @@ docker run -d --name mongo -p 27017:27017 -v mongodb_data_container:/data/db mon # Run backend and worker services docker run -d --name backend -p 5001:5001 \ + --link redis:redis --link mongo:mongo \ -v $(pwd)/application/indexes:/app/indexes \ -v $(pwd)/application/inputs:/app/inputs \ -v $(pwd)/application/vectors:/app/vectors \ -e API_KEY=$OPENAI_API_KEY \ -e EMBEDDINGS_KEY=$OPENAI_API_KEY \ - -e CELERY_BROKER_URL=redis://localhost:6379/0 \ - -e CELERY_RESULT_BACKEND=redis://localhost:6379/1 \ - -e MONGO_URI=mongodb://localhost:27017/docsgpt \ + -e CELERY_BROKER_URL=redis://redis:6379/0 \ + -e CELERY_RESULT_BACKEND=redis://redis:6379/1 \ + -e MONGO_URI=mongodb://mongo:27017/docsgpt \ backend_image docker run -d --name worker \ + --link redis:redis --link mongo:mongo \ -e API_KEY=$OPENAI_API_KEY \ -e EMBEDDINGS_KEY=$OPENAI_API_KEY \ - -e CELERY_BROKER_URL=redis://localhost:6379/0 \ - -e CELERY_RESULT_BACKEND=redis://localhost:6379/1 \ - -e MONGO_URI=mongodb://localhost:27017/docsgpt \ - -e API_URL=http://localhost:5001 \ - backend_image celery -A app.celery worker -l INFO + -e CELERY_BROKER_URL=redis://redis:6379/0 \ + -e CELERY_RESULT_BACKEND=redis://redis:6379/1 \ + -e MONGO_URI=mongodb://mongo:27017/docsgpt \ + -e API_URL=http://backend:5001 \ + backend_image \ + celery -A app.celery worker -l INFO # Run frontend service docker run -d --name frontend -p 5173:5173 \ -e VITE_API_HOST=http://localhost:5001 \ frontend_image -# List running containers -docker ps