This documentation provides a detailed step-by-step guide on configuring Docker within the development environment for the docker/genai-stack
. Below are the methodologies and code snippets necessary for effectively setting up your Docker configuration.
Docker Compose Configuration
The primary configuration resides in the docker-compose.yml
file. This file orchestrates the setup of multiple services that work together during the development of the GenAI stack.
Basic Structure of docker-compose.yml
Here is the essential structure of your docker-compose.yml
file, which defines various services required for development:
services:
llm:
image: ollama/ollama:latest
networks:
- net
llm-gpu:
<<: *llm
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
pull-model:
image: genai-stack/pull-model:latest
build:
context: .
dockerfile: pull_model.Dockerfile
environment:
- OLLAMA_BASE_URL=${OLLAMA_BASE_URL-http://host.docker.internal:11434}
Service Definitions
Each service within the docker-compose.yml
file is defined with specific attributes such as images to be used, build contexts, environment variables, and dependencies. Below are detailed configurations for some of the essential services:
Pull Model Service
The pull-model
service is used to fetch models from a specified source.
pull-model:
image: genai-stack/pull-model:latest
build:
context: .
dockerfile: pull_model.Dockerfile
environment:
- OLLAMA_BASE_URL=${OLLAMA_BASE_URL-http://host.docker.internal:11434}
- LLM=${LLM-llama2}
networks:
- net
Database Service
The database
service utilizes Neo4j, which is commonly used for graph databases. The health checks ensure that the database is up and running before other services attempt to connect.
database:
image: neo4j:5.11
ports:
- 7687:7687
- 7474:7474
volumes:
- $PWD/data:/data
environment:
- NEO4J_AUTH=${NEO4J_USERNAME-neo4j}/${NEO4J_PASSWORD-password}
- NEO4J_PLUGINS=["apoc"]
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider localhost:7474 || exit 1"]
interval: 15s
timeout: 30s
retries: 10
networks:
- net
Loader Service
This service pulls various models and operates on given embeddings.
loader:
build:
context: .
dockerfile: loader.Dockerfile
volumes:
- $PWD/embedding_model:/embedding_model
environment:
- NEO4J_URI=${NEO4J_URI-neo4j://database:7687}
- NEO4J_PASSWORD=${NEO4J_PASSWORD-password}
networks:
- net
depends_on:
database:
condition: service_healthy
pull-model:
condition: service_completed_successfully
ports:
- 8081:8080
Development Specifics
To streamline the development process, various services include x-develop
configurations. This setting automatically rebuilds or syncs components when changes are detected.
For example, within the loader
service:
loader:
x-develop:
watch:
- action: rebuild
path: .
ignore:
- bot.py
- pdf_bot.py
Network Configuration
To facilitate communication between services, a shared network named net
is declared:
networks:
net:
Running the Configuration
After saving the docker-compose.yml
file, use the following command to start the development environment:
docker-compose up --build
This command will build the necessary images and start the defined services in a single command.
Conclusion
This document has outlined the necessary steps to configure your Docker setup in the development environment of the docker/genai-stack
. By following these guidelines, developers can ensure a seamless workflow, integrating all required services effectively without any unnecessary duplication.
Source: docker/genai-stack documentation provided.