Spaces:
Sleeping
Sleeping
| # Base image | |
| FROM python:3.10-slim | |
| # Environment setup | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| # Set Hugging Face cache dirs (writable) | |
| ENV HF_HOME=/tmp/.hf_cache | |
| ENV HF_DATASETS_CACHE=/tmp/.hf_cache | |
| ENV TRANSFORMERS_CACHE=/tmp/.hf_cache | |
| ENV TMPDIR=/tmp | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| libatlas3-base \ | |
| libopenblas-dev \ | |
| git \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create a non-root user for Hugging Face Spaces | |
| RUN useradd -m -u 1000 user | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy requirements first (for caching) | |
| COPY requirements.txt . | |
| # Install Python packages | |
| RUN python -m pip install --upgrade pip setuptools wheel && \ | |
| pip install --no-cache-dir numpy && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Copy the entire repo (so fintech_project/ is available) | |
| COPY --chown=user:user . . | |
| # Create cache directories with proper permissions | |
| RUN mkdir -p /tmp/.hf_cache && \ | |
| chmod -R 777 /tmp && \ | |
| chown -R user:user /app | |
| # Switch to non-root user | |
| USER user | |
| # Expose Streamlit port | |
| EXPOSE 8501 | |
| # Run Streamlit app inside subdirectory | |
| CMD ["streamlit", "run", "fintech_project/app.py", "--server.port=8501", "--server.headless=true"] | |