File size: 923 Bytes
f1be4cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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"]