Nighty3912 commited on
Commit
c40dd75
·
verified ·
1 Parent(s): 10e36a3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -11
Dockerfile CHANGED
@@ -1,13 +1,11 @@
1
- # Use Python 3.11 base image
2
  FROM python:3.11.4-slim
3
 
4
- # Avoid interactive prompts
5
  ENV DEBIAN_FRONTEND=noninteractive
6
-
7
- # Set working directory
8
  WORKDIR /app
9
 
10
- # Install OS-level dependencies
11
  RUN apt-get update && apt-get install -y \
12
  git \
13
  build-essential \
@@ -18,21 +16,31 @@ RUN apt-get update && apt-get install -y \
18
  libxrender-dev \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
- # Upgrade pip and install build tools
22
  RUN pip install --upgrade pip setuptools wheel build
23
 
24
- # Manually install Ultralytics CLIP fork using legacy build mode
25
  RUN pip install --no-use-pep517 git+https://github.com/ultralytics/CLIP.git
26
 
27
- # Copy requirements.txt and install remaining dependencies
 
 
 
 
 
 
 
 
 
 
28
  COPY requirements.txt .
29
  RUN pip install --no-cache-dir -r requirements.txt
30
 
31
- # Copy the rest of the application code
32
  COPY . .
33
 
34
- # Expose Gradio’s port (Hugging Face Spaces uses this)
35
  EXPOSE 7860
36
 
37
- # Start the application (adjust if your entrypoint file is named differently)
38
  CMD ["python", "app.py"]
 
1
+ # Use Python 3.11 image (adjust as needed)
2
  FROM python:3.11.4-slim
3
 
4
+ # Avoid interactive prompts and set workdir
5
  ENV DEBIAN_FRONTEND=noninteractive
 
 
6
  WORKDIR /app
7
 
8
+ # Install system dependencies (git, build tools, etc.)
9
  RUN apt-get update && apt-get install -y \
10
  git \
11
  build-essential \
 
16
  libxrender-dev \
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
+ # Upgrade pip, setuptools, wheel, and build
20
  RUN pip install --upgrade pip setuptools wheel build
21
 
22
+ # Force installation of Ultralytics' CLIP fork using legacy build mode
23
  RUN pip install --no-use-pep517 git+https://github.com/ultralytics/CLIP.git
24
 
25
+ # (Optional) Rename the installed package folder if it’s installed as "CLIP"
26
+ # so that later "import clip" succeeds.
27
+ RUN python -c "import os, site; \
28
+ sp = site.getsitepackages()[0]; \
29
+ src = os.path.join(sp, 'CLIP'); \
30
+ dst = os.path.join(sp, 'clip'); \
31
+ print('Looking for', src); \
32
+ print('Renaming to', dst) if os.path.exists(src) else print('Not needed'); \
33
+ os.rename(src, dst) if os.path.exists(src) else None"
34
+
35
+ # Copy requirements file and install remaining requirements (ensure no CLIP mention here)
36
  COPY requirements.txt .
37
  RUN pip install --no-cache-dir -r requirements.txt
38
 
39
+ # Copy your app code (if any)
40
  COPY . .
41
 
42
+ # Expose port (if using a web server like Gradio)
43
  EXPOSE 7860
44
 
45
+ # Start your app (adjust entrypoint as needed)
46
  CMD ["python", "app.py"]