Spaces:
Paused
Paused
File size: 1,778 Bytes
287f3d3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # ==============================================================================
# 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}"]
|