| # Use an official Python runtime as the base image | |
| FROM python:3.9-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| git \ | |
| libgl1-mesa-glx \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install Cog | |
| RUN pip install cog==0.9.7 | |
| # Copy the repository files | |
| COPY . . | |
| # Install Python dependencies from requirements.txt | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Download weights at runtime using the HF_TOKEN from the environment | |
| # Assuming script/download-weights uses HF_TOKEN env var | |
| RUN echo "Weights will be downloaded at runtime using HF_TOKEN" | |
| # Expose the port Cog typically uses | |
| EXPOSE 5000 | |
| # Set environment variable to disable GPU (force CPU) | |
| ENV CUDA_VISIBLE_DEVICES="" | |
| # Command to run the Cog server, downloading weights if needed | |
| CMD ["sh", "-c", "cog run script/download-weights $HF_TOKEN && cog run -p 5000"] |