# ============================================================================ # SALES BOT - Dockerfile # ============================================================================ # # Imagen base con Python 3.12 y Tesseract OCR # FROM python:3.12-slim # Metadata LABEL maintainer="sales-bot-team" LABEL description="Sales Bot - Sistema de ventas con Mattermost y OCR" LABEL version="1.0.0" # Variables de entorno ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ DEBIAN_FRONTEND=noninteractive # Instalar dependencias del sistema RUN apt-get update && apt-get install -y --no-install-recommends \ # Tesseract OCR tesseract-ocr \ tesseract-ocr-eng \ tesseract-ocr-spa \ libtesseract-dev \ # Dependencias de procesamiento de imágenes libsm6 \ libxext6 \ libxrender-dev \ libgomp1 \ libglib2.0-0 \ libgl1 \ # Utilidades curl \ && rm -rf /var/lib/apt/lists/* # Crear usuario no-root RUN useradd -m -u 1000 -s /bin/bash salesbot # Establecer directorio de trabajo WORKDIR /app # Copiar requirements primero (para aprovechar cache de Docker) COPY requirements.txt . # Instalar dependencias Python RUN pip install --no-cache-dir -r requirements.txt # Copiar código de la aplicación COPY --chown=salesbot:salesbot . . # Crear directorio de logs RUN mkdir -p /app/logs && chown -R salesbot:salesbot /app/logs # Cambiar a usuario no-root USER salesbot # Exponer puerto EXPOSE 5000 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:5000/health || exit 1 # Comando de inicio CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "1", "--timeout", "60", "--access-logfile", "-", "--error-logfile", "-", "app:app"]