# Multi-stage build for Strat-Chatbot FROM python:3.12-slim AS builder WORKDIR /app # Install system dependencies for sentence-transformers (PyTorch, etc.) RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ g++ \ && rm -rf /var/lib/apt/lists/* # Install Poetry RUN pip install --no-cache-dir poetry # Copy dependencies COPY pyproject.toml ./ COPY README.md ./ # Install dependencies RUN poetry config virtualenvs.in-project true && \ poetry install --no-interaction --no-ansi --only main # Final stage FROM python:3.12-slim WORKDIR /app # Copy virtual environment from builder COPY --from=builder /app/.venv .venv ENV PATH="/app/.venv/bin:$PATH" # Create non-root user RUN useradd --create-home --shell /bin/bash app && chown -R app:app /app USER app # Copy application code COPY --chown=app:app app/ ./app/ COPY --chown=app:app data/ ./data/ COPY --chown=app:app scripts/ ./scripts/ # Create data directories RUN mkdir -p data/chroma data/rules # Expose ports EXPOSE 8000 # Run FastAPI server CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]