File size: 1,821 Bytes
e391a84 | 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 52 53 | # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Dockerfile β BP Monitoring Pipeline (HF Spaces deployment)
# Base: Python 3.11 slim
# Port: 7860 (HF Spaces default)
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
FROM python:3.11-slim
# Metadata
LABEL maintainer="Data Engineering Team"
LABEL description="BP Monitoring Pipeline β FastAPI ETL #1"
LABEL version="1.0.0"
# HF Spaces requires non-root user named 'user' with UID 1000
RUN useradd -m -u 1000 user
# Set working directory
WORKDIR /app
# Install system dependencies for SciPy / asyncpg
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy dependency definitions first (layer caching)
COPY pyproject.toml ./
# Install Python dependencies (exclude GPU extras in the API container)
RUN pip install --no-cache-dir -e "." && \
pip install --no-cache-dir uvicorn[standard]
# Copy source code
COPY src/ ./src/
COPY migrations/ ./migrations/
COPY alembic.ini ./
# Change ownership to user
RUN chown -R user:user /app
USER user
# Expose HF Spaces port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD python -c "import httpx; httpx.get('http://localhost:7860/health').raise_for_status()"
# Start FastAPI
CMD ["uvicorn", "src.interface.api.app:create_app", "--factory", \
"--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|