From fb10a546d6fe132705ea5afe2750cdaf97a694b0 Mon Sep 17 00:00:00 2001 From: Anton Larin Date: Sat, 17 Jun 2023 13:35:05 +0200 Subject: [PATCH] running with docker-compose with .sh script for more convenience with Azure. --- README.md | 2 +- docker-compose-azure.yaml | 69 ++++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 6 ---- run-with-docker-compose.sh | 9 +++++ 4 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 docker-compose-azure.yaml create mode 100755 run-with-docker-compose.sh diff --git a/README.md b/README.md index 0c0b1480..bbc0e556 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Note: Make sure you have docker installed OPENAI_API_KEY=Yourkey VITE_API_STREAMING=true ``` -3. Run `docker-compose build && docker-compose up` +3. Run `./run-with-docker-compose.sh` 4. Navigate to http://localhost:5173/ To stop just run Ctrl + C diff --git a/docker-compose-azure.yaml b/docker-compose-azure.yaml new file mode 100644 index 00000000..81c67c21 --- /dev/null +++ b/docker-compose-azure.yaml @@ -0,0 +1,69 @@ +version: "3.9" + +services: + frontend: + build: ./frontend + environment: + - VITE_API_HOST=http://localhost:5001 + - VITE_API_STREAMING=$VITE_API_STREAMING + ports: + - "5173:5173" + depends_on: + - backend + + backend: + build: ./application + environment: + - API_KEY=$OPENAI_API_KEY + - EMBEDDINGS_KEY=$OPENAI_API_KEY + - CELERY_BROKER_URL=redis://redis:6379/0 + - CELERY_RESULT_BACKEND=redis://redis:6379/1 + - MONGO_URI=mongodb://mongo:27017/docsgpt + - OPENAI_API_BASE=$OPENAI_API_BASE + - OPENAI_API_VERSION=$OPENAI_API_VERSION + - AZURE_DEPLOYMENT_NAME=$AZURE_DEPLOYMENT_NAME + - AZURE_EMBEDDINGS_DEPLOYMENT_NAME=$AZURE_EMBEDDINGS_DEPLOYMENT_NAME + ports: + - "5001:5001" + volumes: + - ./application/indexes:/app/indexes + - ./application/inputs:/app/inputs + - ./application/vectors:/app/vectors + depends_on: + - redis + - mongo + + worker: + build: ./application + command: celery -A app.celery worker -l INFO + environment: + - API_KEY=$OPENAI_API_KEY + - EMBEDDINGS_KEY=$OPENAI_API_KEY + - CELERY_BROKER_URL=redis://redis:6379/0 + - CELERY_RESULT_BACKEND=redis://redis:6379/1 + - MONGO_URI=mongodb://mongo:27017/docsgpt + - API_URL=http://backend:5001 + - OPENAI_API_BASE=$OPENAI_API_BASE + - OPENAI_API_VERSION=$OPENAI_API_VERSION + - AZURE_DEPLOYMENT_NAME=$AZURE_DEPLOYMENT_NAME + - AZURE_EMBEDDINGS_DEPLOYMENT_NAME=$AZURE_EMBEDDINGS_DEPLOYMENT_NAME + depends_on: + - redis + - mongo + + redis: + image: redis:6-alpine + ports: + - 6379:6379 + + mongo: + image: mongo:6 + ports: + - 27017:27017 + volumes: + - mongodb_data_container:/data/db + + + +volumes: + mongodb_data_container: \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index c9557dc5..c06b61bf 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -19,9 +19,6 @@ services: - CELERY_BROKER_URL=redis://redis:6379/0 - CELERY_RESULT_BACKEND=redis://redis:6379/1 - MONGO_URI=mongodb://mongo:27017/docsgpt - #- OPENAI_API_BASE=$OPENAI_API_BASE - #- OPENAI_API_VERSION=$OPENAI_API_VERSION - #- AZURE_DEPLOYMENT_NAME=$AZURE_DEPLOYMENT_NAME ports: - "5001:5001" volumes: @@ -42,9 +39,6 @@ services: - CELERY_RESULT_BACKEND=redis://redis:6379/1 - MONGO_URI=mongodb://mongo:27017/docsgpt - API_URL=http://backend:5001 - #- OPENAI_API_BASE=$OPENAI_API_BASE - #- OPENAI_API_VERSION=$OPENAI_API_VERSION - #- AZURE_DEPLOYMENT_NAME=$AZURE_DEPLOYMENT_NAME depends_on: - redis - mongo diff --git a/run-with-docker-compose.sh b/run-with-docker-compose.sh new file mode 100755 index 00000000..f59cf93b --- /dev/null +++ b/run-with-docker-compose.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +source .env + +if [[ -n "$OPENAI_API_BASE" ]] && [[ -n "$OPENAI_API_VERSION" ]] && [[ -n "$AZURE_DEPLOYMENT_NAME" ]] && [[ -n "$AZURE_EMBEDDINGS_DEPLOYMENT_NAME" ]]; then + docker-compose -f docker-compose-azure.yaml build && docker-compose -f docker-compose-azure.yaml up +else + docker-compose build && docker-compose up +fi