Skip to content

Commit

Permalink
fix: update deployment guide
Browse files Browse the repository at this point in the history
  • Loading branch information
wd0517 committed Aug 6, 2024
1 parent 375b816 commit 2f5b2b6
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 29 deletions.
30 changes: 30 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ENVIRONMENT=production

# You can generate a new secret key by running the following command
# $ python3 -c "import secrets; print(secrets.token_urlsafe(32))"
# SECRET_KEY is very important, please do not share it with others,
# SECRET_KEY must greater or equal to 32 characters.
SECRET_KEY=

# Replace with your own sentry dsn
# SENTRY_DSN=https://[email protected]/4507549478223872

# Replace with your own TiDB Serverless connection information,
# currently only TiDB Serverless supports vector search.
# You can quickly create one from https://tidbcloud.com/
TIDB_HOST=xxxxx.prod.aws.tidbcloud.com
TIDB_USER=
TIDB_PASSWORD=
TIDB_DATABASE=


# Replace with your own Jina AI API key
# You can get one from https://jina.ai/reranker/
JINAAI_API_KEY=


# DO NOT CHANGE BELOW CONFIGURATIONS UNLESS YOU KNOW WHAT YOU ARE DOING
CELERY_BROKER_URL=redis://redis:6379/0
CELERY_RESULT_BACKEND=redis://redis:6379/0

DSP_CACHEBOOL=false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.env

redis-data
data
venv
36 changes: 27 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,46 @@ A conversational search tool based on GraphRAG (Knowledge Graph) that built on t
cd tidb.ai
```

2. Copy and edit the `.env` file in the `backend` directory:
2. Copy and edit the `.env` file:

```bash
cp ./backend/.env.example ./backend/.env
vim ./backend/.env # or use another text editor to edit this file
cp .env.example .env
vim .env # or use another text editor to edit this file
```

3. Migrate the database schema:
Replace the following placeholders with your own values:
- `SECRET_KEY`: you can generate a random secret key using `python3 -c "import secrets; print(secrets.token_urlsafe(32))"`
- `JINAAI_API_KEY`: get one from [Jina AI](https://jina.ai/reranker/)
- `TIDB_HOST`, `TIDB_USER`, `TIDB_PASSWORD` and `TIDB_DATABASE`: get them from your [TiDB Serverless cluster](https://tidbcloud.com/)

3. Build docker images:

```bash
docker compose build
```

4. Migrate the database schema:

```bash
cd backend
rye sync
make migrate
cd ..
docker compose run backend /bin/sh -c "alembic upgrade head"
```

4. Start the services using Docker Compose:
5. Bootstrap the database with initial data:

```bash
docker compose run backend /bin/sh -c "python bootstrap.py"
```

Running the bootstrap script creates an admin user. You can find the username and password in the output.

6. Start the services:

```bash
docker compose up
```

7. Open your browser and visit `http://localhost:3000` to access the web interface.

## Tech Stack

- [TiDB](https://pingcap.com/ai/?utm_source=github&utm_medium=tidb.ai) – Database to store chat history, vector, json, and analytic
Expand Down
15 changes: 0 additions & 15 deletions backend/.env.example

This file was deleted.

2 changes: 0 additions & 2 deletions backend/prestart.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#! /usr/bin/env bash

python /app/bootstrap.py
9 changes: 6 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ services:
ports:
- "5000:80"
env_file:
- ./backend/.env
- .env
volumes:
- ./data:/shared/data
logging:
driver: json-file
options:
Expand Down Expand Up @@ -49,11 +51,12 @@ services:
restart: always
depends_on:
- redis
- backend
ports:
- "5555:5555"
env_file:
- ./backend/.env
- .env
volumes:
- ./data:/shared/data
command: /usr/bin/supervisord
logging:
driver: json-file
Expand Down

0 comments on commit 2f5b2b6

Please sign in to comment.