Naman712 commited on
Commit
90842f3
·
verified ·
1 Parent(s): 7769704

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -9
Dockerfile CHANGED
@@ -1,29 +1,34 @@
1
- # Use Python 3.10 Slim Bookworm (Stable & Lightweight)
2
- FROM python:3.10-slim-bookworm
3
 
4
- # 1. Install system dependencies
5
- # libgl1/libglib2.0 are needed for image processing libraries
6
  RUN apt-get update && apt-get install -y \
7
  git \
8
  libgl1 \
9
  libglib2.0-0 \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # 2. Setup User (Security Requirement for Spaces)
13
  RUN useradd -m -u 1000 user
14
  RUN mkdir -p /app && chown user:user /app
15
 
16
- # 3. Switch to user
17
  USER user
18
  ENV PATH="/home/user/.local/bin:$PATH"
19
  WORKDIR /app
20
 
21
- # 4. Install Dependencies (Cached)
 
 
 
 
 
 
 
22
  COPY --chown=user ./requirements.txt requirements.txt
23
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
24
 
25
- # 5. Copy Application
26
  COPY --chown=user . /app
27
 
28
- # 6. Start Server
29
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use Python 3.11 (Newer, fresher environment to avoid 3.10 caches)
2
+ FROM python:3.11-slim-bookworm
3
 
4
+ # 1. Install system dependencies (git is required for the install below)
 
5
  RUN apt-get update && apt-get install -y \
6
  git \
7
  libgl1 \
8
  libglib2.0-0 \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
+ # 2. Setup User
12
  RUN useradd -m -u 1000 user
13
  RUN mkdir -p /app && chown user:user /app
14
 
 
15
  USER user
16
  ENV PATH="/home/user/.local/bin:$PATH"
17
  WORKDIR /app
18
 
19
+ # 3. FORCE INSTALL TORCH CPU (Saves massive space & RAM)
20
+ RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
21
+
22
+ # 4. FORCE INSTALL TRANSFORMERS (The Fix)
23
+ # We install directly to ensure we get the version that supports Florence-2
24
+ RUN pip install --no-cache-dir --upgrade transformers>=4.46.0
25
+
26
+ # 5. Install other dependencies
27
  COPY --chown=user ./requirements.txt requirements.txt
28
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
29
 
30
+ # 6. Copy Application
31
  COPY --chown=user . /app
32
 
33
+ # 7. Start
34
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]