Spaces:
Running
Running
# Use an official Python 3.11 slim image | |
FROM python:3.11.4-slim | |
# Avoid interactive prompts during build | |
ENV DEBIAN_FRONTEND=noninteractive | |
# Set working directory | |
WORKDIR /app | |
# Install system dependencies (git, build tools, etc.) | |
RUN apt-get update && apt-get install -y \ | |
git \ | |
build-essential \ | |
ffmpeg \ | |
libglib2.0-0 \ | |
libsm6 \ | |
libxext6 \ | |
libxrender-dev \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Upgrade pip, setuptools, wheel, and build tools | |
RUN pip install --upgrade pip setuptools wheel build | |
# Force installation of Ultralytics' CLIP fork with legacy build flags | |
RUN pip install --no-cache-dir --no-build-isolation --no-use-pep517 git+https://github.com/ultralytics/CLIP.git | |
# Optionally rename installed package folder from "CLIP" to "clip" (for case-sensitive imports) | |
RUN python -c "import os, site; sp = site.getsitepackages()[0]; \ | |
src = os.path.join(sp, 'CLIP'); dst = os.path.join(sp, 'clip'); \ | |
print('Found folder:', src) if os.path.exists(src) else print('Folder not found, skipping renaming'); \ | |
os.rename(src, dst) if os.path.exists(src) else None" | |
# Copy requirements file and install remaining dependencies (ensure no duplicate references to CLIP) | |
COPY requirements.txt . | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the rest of your application code into the container | |
COPY . . | |
# Expose port 7860 (if using a web server like Gradio) | |
EXPOSE 7860 | |
# Run the application (adjust the command if your entrypoint is different) | |
CMD ["python", "app.py"] | |