Spaces:
Running
Running
File size: 2,547 Bytes
09cd93c 9f49815 226ac39 9f49815 226ac39 9f49815 226ac39 9f49815 226ac39 9f49815 226ac39 9f49815 226ac39 9f49815 226ac39 9f49815 226ac39 9f49815 226ac39 9f49815 226ac39 9f49815 226ac39 9f49815 226ac39 09cd93c 9f49815 09cd93c 226ac39 09cd93c 226ac39 9f49815 09cd93c 226ac39 09cd93c 9f49815 09cd93c 226ac39 09cd93c 226ac39 bdf714a 09cd93c 226ac39 09cd93c |
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# ===============================
# HuggingFace Spaces Dockerfile
# ===============================
# Optimized for 16GB RAM, Port 7860
# ===============================
# Stage 1: Build Frontend
# ===============================
FROM node:20-alpine AS frontend-builder
WORKDIR /frontend
COPY FRRONTEEEND/package*.json ./
RUN npm install
COPY FRRONTEEEND/ ./
RUN npm run build
# ===============================
# Stage 2: Build Python environment
# ===============================
FROM python:3.12-slim AS builder
# Install build dependencies (needed for ML wheels)
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
make \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Upgrade pip tooling
RUN pip install --upgrade pip setuptools wheel
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# ===============================
# Stage 3: Runtime environment
# ===============================
FROM python:3.12-slim
# Install runtime shared libraries
RUN apt-get update && apt-get install -y --no-install-recommends \
libgomp1 \
libstdc++6 \
&& rm -rf /var/lib/apt/lists/*
# Copy virtual environment
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Create non-root user for HuggingFace Spaces
RUN useradd -m -u 1000 user
USER user
# App working directory
WORKDIR /home/user/app
# Copy backend code (as user)
COPY --chown=user:user src/ ./src/
COPY --chown=user:user examples/ ./examples/
# Copy frontend build
COPY --from=frontend-builder --chown=user:user /frontend/dist ./FRRONTEEEND/dist
# HuggingFace Spaces directories (user-writable)
RUN mkdir -p \
/home/user/app/data \
/home/user/app/outputs/models \
/home/user/app/outputs/plots \
/home/user/app/outputs/reports \
/home/user/app/outputs/data \
/home/user/app/cache_db
# Environment variables for HuggingFace Spaces
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
ENV OUTPUT_DIR=/home/user/app/outputs
ENV CACHE_DB_PATH=/home/user/app/cache_db/cache.db
ENV ARTIFACT_BACKEND=local
# YData Profiling optimization for 16GB RAM (HuggingFace Spaces)
# Higher thresholds = better quality reports without sampling
ENV YDATA_MAX_ROWS=200000
ENV YDATA_MAX_SIZE_MB=100
ENV YDATA_SAMPLE_SIZE=150000
# HuggingFace Spaces uses port 7860 by default
EXPOSE 7860
# Start FastAPI on port 7860
CMD ["uvicorn", "src.api.app:app", "--host", "0.0.0.0", "--port", "7860"]
|