Spaces:
Paused
Paused
| # ============================================================================== | |
| # B2D — Business to Development Dockerfile | |
| # Production-ready multi-stage containerization with non-root security context | |
| # ============================================================================== | |
| FROM python:3.11-slim AS base | |
| # Prevent Python from writing .pyc files and buffer stdout/stderr | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PIP_DISABLE_PIP_VERSION_CHECK=1 | |
| WORKDIR /app | |
| # Install system dependencies (curl for healthcheck) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy dependencies manifest first to leverage Docker layer caching | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Create non-root user for security compliance | |
| RUN groupadd -g 10001 appgroup && \ | |
| useradd -u 10001 -g appgroup -s /bin/bash -m appuser && \ | |
| mkdir -p /app/data /app/data/runs /app/data/artifacts && \ | |
| chown -R appuser:appgroup /app | |
| # Copy application source code | |
| COPY backend/ ./backend/ | |
| COPY agentic_core/ ./agentic_core/ | |
| COPY scripts/ ./scripts/ | |
| COPY README.md pytest.ini ./ | |
| # Ensure correct permissions for non-root execution | |
| RUN chown -R appuser:appgroup /app | |
| USER appuser | |
| # Expose default port (8000) and Hugging Face Spaces port (7860) | |
| EXPOSE 8000 7860 | |
| # Health check configuration | |
| HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ | |
| CMD curl -f http://localhost:${PORT:-7860}/api/health || exit 1 | |
| # Launch uvicorn server with PORT fallback (7860 for Hugging Face Spaces) | |
| CMD ["sh", "-c", "uvicorn backend.app:app --host 0.0.0.0 --port ${PORT:-7860}"] | |