| # Use a lightweight official Python image | |
| FROM python:3.11-slim | |
| # Install system dependencies required for C++ binaries, file operations, and curl | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| curl \ | |
| libgomp1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set up a working directory inside the container | |
| WORKDIR /code | |
| # Copy requirement configuration file first to leverage Docker layer caching | |
| COPY ./requirements.txt /code/requirements.txt | |
| # Install python dependencies | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| # Copy the rest of your application code into the container | |
| COPY . . | |
| # CRITICAL: Grant executable permissions to your C++ inference binary | |
| RUN chmod +x /code/fastvlm_server | |
| # Create a secure temporary directory for permissions compliance on Hugging Face | |
| RUN mkdir -p /tmp && chmod 777 /tmp | |
| ENV TMPDIR=/tmp | |
| # Hugging Face Spaces expect containers to listen on port 7860 | |
| EXPOSE 7860 | |
| RUN chmod +x /code/start.sh | |
| # Run the orchestration script | |
| CMD ["./start.sh"] |