Docker Compose Configuration
In the development environment, the docker-compose.yml
file is critical for setting up the various services required for the application. Below is an explanation of each service block along with configuration options:
Redis Service
redis:
image: redis:6.0.16
restart: always
volumes:
- ./redis-data:/data
command: ["redis-server", "--loglevel", "warning"]
- image: Specifies which version of Redis to use.
- restart: Ensures the service restarts automatically on failure.
- volumes: Maps a local directory to the Redis data directory for persistent storage.
- command: Sets the log level of the Redis server to minimize logs during operation.
Backend Service
backend:
image: tidbai/backend:0.2.8
restart: always
depends_on:
- redis
ports:
- "8000:80"
env_file:
- .env
volumes:
- ./data:/shared/data
logging:
driver: json-file
options:
max-size: "50m"
max-file: "6"
- image: Defines the version of the backend service.
- depends_on: Ensures Redis is started before the backend service.
- ports: Maps port 8000 on the host to port 80 on the container.
- env_file: Indicates that environment variables will be loaded from the
.env
file. - volumes: Similar to Redis, it allows data to be shared between the host and the container.
- logging: Configures logging behavior to manage log file sizes.
Frontend Service
frontend:
image: tidbai/frontend:0.2.8
restart: always
depends_on:
- backend
ports:
- 3000:3000
environment:
BASE_URL: http://backend
logging:
driver: json-file
options:
max-size: "50m"
max-file: "6"
- image: Specifies the version of the frontend service.
- depends_on: Ensures the backend service is up and running first.
- ports: Exposes port 3000 for the frontend interface.
- environment: Sets the base URL for API requests made from the frontend.
Background Service
background:
image: tidbai/backend:0.2.8
restart: always
depends_on:
- redis
ports:
- "5555:5555"
env_file:
- .env
volumes:
- ./data:/shared/data
command: /usr/bin/supervisord
logging:
driver: json-file
options:
max-size: "50m"
max-file: "6"
- command: Overrides the default command to run the Supervisor process, allowing the management of multiple processes.
Local Embedding Reranker Service
local-embedding-reranker:
image: tidbai/local-embedding-reranker:v3-with-cache
ports:
- 5001:5001
environment:
- PRE_LOAD_DEFAULT_EMBEDDING_MODEL=true
- PRE_LOAD_DEFAULT_RERANKER_MODEL=false
- TRANSFORMERS_OFFLINE=1
- environment: Activates features related to pre-loading embedding and reranker models, controlling behavior based on whether GPU support is enabled.
Profiles Block
profiles:
- local-embedding-reranker
- profiles: Allows for specific configurations to be activated, in this case, the local embedding reranker.
Environment Variables
The .env
file contains sensitive information and configurations. Below is an example configuration and essential notes:
ENVIRONMENT=production
SECRET_KEY=
TIDB_HOST=xxxxx.prod.aws.tidbcloud.com
TIDB_USER=
TIDB_PASSWORD=
TIDB_DATABASE=
TIDB_SSL=true
EMBEDDING_DIMS=1536
EMBEDDING_MAX_TOKENS=8191
- SECRET_KEY: Generate a secure key for the application using the provided Python command to ensure it meets security requirements.
$ python3 -c "import secrets; print(secrets.token_urlsafe(32))"
TIDB settings: Fill in your TiDB connection details. TiDB Serverless is highly recommended for simplicity.
EMBEDDING_DIMS and EMBEDDING_MAX_TOKENS: These configurations are crucial for embedding model specifications. Ensure they are compatible with the embedding model being used.
The configuration steps outlined above should allow for the successful set-up of your development environment using pingcap/autoflow
.
Source: Given configuration files and environment variable examples.