Deploy with Docker Compose
This document provides instructions for deploying the entire Autoflow application using Docker Compose.
Prerequisites
- Set up a TiDB cluster, you can use either:
- TiDB Cloud Serverless(recommended)
- TiDB Self-Managed(>=v8.4).
- Install Docker Compose.
Deploy
-
Clone the repository:
git clone https://github.com/pingcap/autoflow.git; cd autoflow/;
-
Copy and edit the
.env
file:cp .env.example .env vim .env # or use another text editor to edit this file
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))"`
TIDB_HOST
,TIDB_USER
,TIDB_PASSWORD
andTIDB_DATABASE
: you can get these values from the TiDB cluster you set up before.- Note: if you are using a self-managed TiDB cluster, you need to set
TIDB_SSL=false
.
- Note: if you are using a self-managed TiDB cluster, you need to set
EMBEDDING_MAX_TOKENS
: set them according to the embedding model you choose before, it can not be changed after the deployment.(We will remove it in the future, and move it to the admin panel)
-
Migrate the database schema:
docker compose run backend /bin/sh -c "alembic upgrade head"
-
Bootstrap the database with initial data:
# Use default admin credentials (admin@example.com with random password) docker compose run backend /bin/sh -c "python bootstrap.py" # Or specify a custom admin email docker compose run backend /bin/sh -c "python bootstrap.py --email new-admin@example.com"
Running the bootstrap script creates an admin user. You can find the username and password in the output.
# Reset admin password (random generated) docker compose run backend /bin/sh -c "python bootstrap.py -r" # Or specify a new password docker compose run backend /bin/sh -c "python bootstrap.py -r --password <new_password>"
-
Start the services:
If you are using a SaaS embedding model, start the services with the following command:
docker compose up
If you want to use the built-in local embedding reranker, start the services with the following command:
docker compose --profile local-embedding-reranker up
-
Done! Now you can open your browser and visit http://localhost:3000 locally
Configuration
After you deploy the application, you need to initialize the application by following quick start guide.
-
Set up the default LLM model in the Models > LLMs page.
-
Set up the default Embedding model in the Models > Embedding Models page.
-
Add a new Knowledge Base in the Knowledge Bases page.
-
Configure default Chat Engine and set up the new knowledge base as the retrieval database.
Upgrade
This section will help you upgrade pingcap/autoflow to the new version.
Suppose you want to upgrade pingcap/autoflow from 0.3.0 to 0.3.1. Follow these steps:
-
Edit your docker-compose.yml file to use the new image version.
services: backend: image: tidbai/backend:0.3.1 frontend: image: tidbai/frontend:0.3.1 background: image: tidbai/backend:0.3.1
-
Pull the new image:
docker compose pull
-
Migrate the database schema:
docker compose run backend /bin/sh -c "alembic upgrade head"
-
Recreate the docker containers:
docker compose up -d --force-recreate
-
Check the logs to ensure everything is working correctly:
docker compose logs -f
-
Done!