Docker
Run HTS MCP with Docker Compose, including PostgreSQL with pgvector.
Docker Compose
version: "3.8"
services:
db:
image: pgvector/pgvector:pg16
environment:
POSTGRES_DB: hts
POSTGRES_USER: hts
POSTGRES_PASSWORD: hts_password
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U hts"]
interval: 5s
timeout: 5s
retries: 5
api:
build: .
ports:
- "8000:8000"
environment:
DATABASE_URL: postgresql://hts:hts_password@db:5432/hts
OPENAI_API_KEY: ${OPENAI_API_KEY}
API_HOST: "0.0.0.0"
API_PORT: "8000"
depends_on:
db:
condition: service_healthy
volumes:
pgdata:Dockerfile
FROM python:3.11-slim
WORKDIR /app
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# Copy project
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev
COPY src/ src/
COPY source-data/ source-data/
# Expose API port
EXPOSE 8000
# Run REST API
CMD ["uv", "run", "uvicorn", "hts.api:app", "--host", "0.0.0.0", "--port", "8000"]Usage
Start Services
# Set your OpenAI key
export OPENAI_API_KEY=sk-...
# Start database and API
docker compose up -dRun Data Pipeline
After the services are running, execute the pipeline inside the container:
# Load data
docker compose exec api uv run hts load general_tariff_data.txt
docker compose exec api uv run hts load-sections hts_sections.csv
docker compose exec api uv run hts load-chapters
# Enrich and embed
docker compose exec api uv run hts enrich-hts6
docker compose exec api uv run hts generate-multilevel-embeddings
# Build graph
docker compose exec api uv run hts generate-graph-edges
docker compose exec api uv run hts classify-graph-edgesVerify
# Check status
docker compose exec api uv run hts status
# Health check
curl http://localhost:8000/health
# Search
curl "http://localhost:8000/api/v1/search?query=steel+pipes"pgvector Image
The pgvector/pgvector:pg16 image includes PostgreSQL 16 with the pgvector extension pre-installed. The extension is automatically available, no manual CREATE EXTENSION needed.
Volume Persistence
The pgdata volume persists database data across container restarts. To reset:
docker compose down -v # removes volumes
docker compose up -d # fresh startEnvironment Variables
Pass all configuration via environment variables in docker-compose.yml or a .env file:
OPENAI_API_KEY=sk-...
API_KEY=your-secret-key
RATE_LIMIT_ENABLED=trueSee Configuration for the complete reference.