Spaces:
Running
Running
| # Use the official Python image that matches the HF Spaces environment | |
| FROM python:3.10-slim | |
| # Set the working directory | |
| WORKDIR /app | |
| # [STEP 1] Install ONLY the necessary system dependencies. | |
| # We need git and git-lfs to clone the model from the Hub. | |
| # We avoid the problematic libgl1-mesa-glx package entirely. | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| git \ | |
| git-lfs \ | |
| && git lfs install \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # [STEP 2] Copy your requirements file and install Python packages. | |
| COPY requirements.txt ./ | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # [STEP 3] Copy the rest of your application code. | |
| COPY . . | |
| # [STEP 4] Set up a non-root user for security. | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| STREAMLIT_SERVER_HEADLESS=true \ | |
| STREAMLIT_SERVER_ENABLE_CORS=false \ | |
| STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false \ | |
| STREAMLIT_BROWSER_GATHER_USAGE_STATS=false | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| # [STEP 5] Expose the Streamlit port and define the command to run the app. | |
| EXPOSE 8501 | |
| CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"] |