Spaces:
Sleeping
Sleeping
| # Use Python 3.10 slim image | |
| FROM python:3.10-slim | |
| # Prevent Python from writing pyc files and buffering stdout/stderr | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| HF_HOME=/tmp/hf_cache | |
| # Set working directory | |
| WORKDIR /code | |
| # Install system dependencies for OpenCV and basic compilation | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy and install python dependencies | |
| COPY requirements.txt /code/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| # Create cache directories and set permissions for Hugging Face container user | |
| RUN mkdir -p /tmp/hf_cache && chmod -R 777 /tmp/hf_cache | |
| # Copy application files | |
| COPY . /code | |
| # Change permissions to make files writable by Hugging Face default user (UID 1000) | |
| RUN chmod -R 777 /code | |
| # Expose port 7860 for Hugging Face Space | |
| EXPOSE 7860 | |
| # Run Streamlit on Hugging Face standard port | |
| CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"] | |