BigBawdi commited on
Commit
15030f4
·
verified ·
1 Parent(s): c99f1a8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -9
Dockerfile CHANGED
@@ -11,29 +11,41 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
11
  libxrender1 \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
- # 2. Set the working directory
15
  WORKDIR /app
16
 
17
- # 3. Copy requirements and install them
18
  COPY requirements.txt .
 
 
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
- # 4. Pre-download the Fashion-CLIP model during the build
22
  RUN python -c "from transformers import CLIPModel, CLIPProcessor; \
23
- model = CLIPModel.from_pretrained('patrickjohncyh/fashion-clip'); \
24
- processor = CLIPProcessor.from_pretrained('patrickjohncyh/fashion-clip'); \
25
  print('Fashion-CLIP model preloaded!')"
26
 
27
- # 5. Copy application code
 
 
 
 
 
28
  COPY . .
29
 
30
- # 6. Create a non-root user
31
  RUN useradd -m -u 1000 user
 
 
 
 
32
  USER user
33
 
34
  ENV HOME=/home/user \
35
  PATH=/home/user/.local/bin:$PATH \
36
- PYTHONUNBUFFERED=1
 
37
 
38
- # 7. Start the application
39
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
11
  libxrender1 \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
+ # 2. Set working directory
15
  WORKDIR /app
16
 
17
+ # 3. Copy requirements
18
  COPY requirements.txt .
19
+
20
+ # 4. Install Python dependencies
21
  RUN pip install --no-cache-dir -r requirements.txt
22
 
23
+ # 5. Download Fashion-CLIP during build
24
  RUN python -c "from transformers import CLIPModel, CLIPProcessor; \
25
+ CLIPModel.from_pretrained('patrickjohncyh/fashion-clip'); \
26
+ CLIPProcessor.from_pretrained('patrickjohncyh/fashion-clip'); \
27
  print('Fashion-CLIP model preloaded!')"
28
 
29
+ # 6. Download YOLO model during build
30
+ RUN python -c "from ultralytics import YOLO; \
31
+ YOLO('yolov8n.pt'); \
32
+ print('YOLO model preloaded!')"
33
+
34
+ # 7. Copy application code
35
  COPY . .
36
 
37
+ # 8. Create non-root user
38
  RUN useradd -m -u 1000 user
39
+
40
+ # 9. Give the application user access to the application directory
41
+ RUN chown -R user:user /app
42
+
43
  USER user
44
 
45
  ENV HOME=/home/user \
46
  PATH=/home/user/.local/bin:$PATH \
47
+ PYTHONUNBUFFERED=1 \
48
+ YOLO_CONFIG_DIR=/tmp/Ultralytics
49
 
50
+ # 10. Start application
51
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]