feat: add Docker deployment for the bot
- Add Dockerfile for Python 3.13 container - Update docker-compose with naliia_bot service - Add DB_HOST config for container networking - Add .dockerignore for build optimization - Update README with Docker documentation
This commit is contained in:
12
.dockerignore
Normal file
12
.dockerignore
Normal file
@@ -0,0 +1,12 @@
|
||||
.git
|
||||
.gitignore
|
||||
*.md
|
||||
__pycache__
|
||||
.pytest_cache
|
||||
.coverage
|
||||
htmlcov
|
||||
.env
|
||||
.venv
|
||||
venv
|
||||
*.pyc
|
||||
.DS_Store
|
||||
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
FROM python:3.13-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN pip install poetry
|
||||
|
||||
COPY pyproject.toml poetry.lock ./
|
||||
RUN poetry install --no-dev --no-interaction
|
||||
|
||||
COPY src/ ./src/
|
||||
COPY .env.example .env
|
||||
|
||||
EXPOSE 8010
|
||||
|
||||
CMD ["poetry", "run", "uvicorn", "src.naliiabotapi.main:app", "--host", "0.0.0.0", "--port", "8010"]
|
||||
51
README.md
51
README.md
@@ -9,6 +9,7 @@ Agente conversacional basado en LangGraph para gestión de agenda y atención al
|
||||
- Integración con modelos LLM (Anthropic Claude, DeepSeek)
|
||||
- API FastAPI para interacción
|
||||
- Checkpointing con PostgreSQL para persistencia de estado
|
||||
- Deploy con Docker y Docker Compose
|
||||
- Tests completos con pytest
|
||||
|
||||
## Estructura del proyecto
|
||||
@@ -36,7 +37,9 @@ NaliiaBot/
|
||||
│ ├── mcp/ # Servidor MCP
|
||||
│ └── ui/ # Frontend
|
||||
├── tests/
|
||||
├── docker-compose.yaml # PostgreSQL para checkpointing
|
||||
├── docker-compose.yaml # PostgreSQL + Bot
|
||||
├── Dockerfile # Imagen del Bot
|
||||
├── .dockerignore
|
||||
├── pyproject.toml # Configuración Poetry
|
||||
└── README.md
|
||||
```
|
||||
@@ -44,11 +47,27 @@ NaliiaBot/
|
||||
## Requisitos
|
||||
|
||||
- Python 3.13+
|
||||
- PostgreSQL (via Docker)
|
||||
- Docker y Docker Compose
|
||||
- MCP server ejecutándose en `http://localhost:8001/mcp`
|
||||
|
||||
## Instalación
|
||||
|
||||
### Docker (Recomendado)
|
||||
|
||||
```bash
|
||||
# Configurar variables de entorno
|
||||
cp .env.example .env
|
||||
# Editar .env con tus configuraciones
|
||||
|
||||
# Iniciar servicios
|
||||
docker-compose up --build
|
||||
|
||||
# Ver logs
|
||||
docker-compose logs -f naliia_bot
|
||||
```
|
||||
|
||||
### Local (Desarrollo)
|
||||
|
||||
```bash
|
||||
# Instalar dependencias con Poetry
|
||||
poetry install
|
||||
@@ -60,14 +79,24 @@ cp .env.example .env
|
||||
|
||||
## Uso
|
||||
|
||||
### Iniciar servicios
|
||||
### Docker
|
||||
|
||||
```bash
|
||||
# Iniciar todos los servicios (PostgreSQL + Bot)
|
||||
docker-compose up -d
|
||||
|
||||
# Detener servicios
|
||||
docker-compose down
|
||||
|
||||
# Reconstruir imagen
|
||||
docker-compose build --no-cache
|
||||
```
|
||||
|
||||
### Desarrollo local
|
||||
|
||||
```bash
|
||||
# Iniciar PostgreSQL
|
||||
docker-compose up -d
|
||||
|
||||
# Iniciar servidor MCP
|
||||
# (configurar según implementación)
|
||||
docker-compose up -d messages_db
|
||||
|
||||
# Iniciar API
|
||||
task dev
|
||||
@@ -86,10 +115,18 @@ task dev
|
||||
| Variable | Descripción | Valor por defecto |
|
||||
|----------|-------------|-------------------|
|
||||
| `LLM_MODEL` | Modelo LLM a usar | `deepseek` |
|
||||
| `POSTGRES_HOST` | Host de PostgreSQL | `localhost` |
|
||||
| `POSTGRES_USER` | Usuario PostgreSQL | `postgres` |
|
||||
| `POSTGRES_PASSWORD` | Contraseña PostgreSQL | `postgres` |
|
||||
| `POSTGRES_DB` | Base de datos | `messages` |
|
||||
|
||||
## Servicios
|
||||
|
||||
| Servicio | Puerto | Descripción |
|
||||
|---------|--------|-------------|
|
||||
| `messages_db` | 5432 | PostgreSQL para checkpointing |
|
||||
| `naliia_bot` | 8010 | API FastAPI del bot |
|
||||
|
||||
## Tools disponibles
|
||||
|
||||
El agente cuenta con las siguientes herramientas:
|
||||
|
||||
@@ -18,5 +18,29 @@ services:
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
naliia_bot:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "8010:8010"
|
||||
depends_on:
|
||||
messages_db:
|
||||
condition: service_healthy
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- LLM_MODEL=${LLM_MODEL:-deepseek}
|
||||
- POSTGRES_HOST=messages_db
|
||||
- POSTGRES_USER=${POSTGRES_USER:-postgres}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
|
||||
- POSTGRES_DB=${POSTGRES_DB:-messages}
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "curl -f http://localhost:8010/health || exit 1"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
volumes:
|
||||
data:
|
||||
|
||||
@@ -6,8 +6,9 @@ from .settings import _settings as st
|
||||
|
||||
|
||||
_protocol = "postgresql://"
|
||||
_connection_string =\
|
||||
f"{_protocol}{st.DB_USER}:{st.DB_PASSWORD}@localhost:5432/{st.DB_NAME}"
|
||||
_connection_string = (
|
||||
f"{_protocol}{st.DB_USER}:{st.DB_PASSWORD}@{st.DB_HOST}:5432/{st.DB_NAME}"
|
||||
)
|
||||
agent_instance: Agent | None = None
|
||||
db_pool = None
|
||||
|
||||
@@ -26,8 +27,5 @@ def get_async_connection_pool():
|
||||
conninfo=_connection_string,
|
||||
max_size=20,
|
||||
open=False,
|
||||
kwargs={
|
||||
"autocommit": True,
|
||||
"prepare_threshold": 0,
|
||||
"row_factory": dict_row
|
||||
})
|
||||
kwargs={"autocommit": True, "prepare_threshold": 0, "row_factory": dict_row},
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ class Settings:
|
||||
DB_NAME = os.getenv("POSTGRES_DB", "messages")
|
||||
DB_USER = os.getenv("POSTGRES_USER", "postgres")
|
||||
DB_PASSWORD = os.getenv("POSTGRES_PASSWORD", "postgres")
|
||||
DB_HOST = os.getenv("POSTGRES_HOST", "localhost")
|
||||
|
||||
def __init__(self):
|
||||
load_dotenv()
|
||||
|
||||
Reference in New Issue
Block a user