NexaCoders commited on
Commit
1027cee
·
verified ·
1 Parent(s): e7d4d92

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -14
Dockerfile CHANGED
@@ -1,24 +1,40 @@
1
- # HF Spaces specific (Gradio + Zero config)
2
  FROM gradio/all:4.16-cuda11.8
3
 
4
  WORKDIR /app
5
 
6
- # Pre-install heavy deps
7
- RUN pip install mediapipe==0.10.7 opencv-python-headless==4.8.1.78
 
 
 
 
 
8
 
9
- COPY . .
 
 
10
 
11
- # Auto-generate clothes
12
- RUN python -c "
13
- import requests
14
- from PIL import Image
15
- import os
16
- os.makedirs('static/sample_clothes', exist_ok=True)
17
- # Add 20 quick sample downloads...
18
- print('✅ Sample clothes ready!')
19
- "
 
 
 
 
 
 
20
 
 
21
  EXPOSE 7860
22
 
23
- # HF Spaces auto-detects Gradio
 
 
24
  CMD ["python", "app.py"]
 
1
+ # HF Spaces + Production Ready (FIXED)
2
  FROM gradio/all:4.16-cuda11.8
3
 
4
  WORKDIR /app
5
 
6
+ # Install dependencies first (cache)
7
+ RUN pip install --no-cache-dir \
8
+ mediapipe==0.10.7 \
9
+ opencv-python-headless==4.8.1.78 \
10
+ pillow==10.0.1 \
11
+ numpy==1.24.3 \
12
+ scipy==1.11.4
13
 
14
+ # Copy source code
15
+ COPY app.py model.py advanced_fitter.py ./
16
+ COPY static/ static/
17
 
18
+ # Create sample clothes (SIMPLE single line)
19
+ RUN python -c "\
20
+ import requests, json, os; \
21
+ os.makedirs('static/sample_clothes', exist_ok=True); \
22
+ sample_catalog = []; \
23
+ sample_urls = {'shirt':['https://images.unsplash.com/photo-1521572163474-6864f9cf17ab?w=256'], 'pants':['https://images.unsplash.com/photo-1542272604-787c3835535d?w=256'], 'dress':['https://images.unsplash.com/photo-1572635196237-14b3f281503f?w=256']}; \
24
+ for t, urls in sample_urls.items(): \
25
+ for i, url in enumerate(urls): \
26
+ try: \
27
+ img = requests.get(url).content; \
28
+ from PIL import Image; img = Image.open(io.BytesIO(img)).resize((256,384)); \
29
+ img.save(f'static/sample_clothes/{t}_{i}.png'); \
30
+ sample_catalog.append({'image_path':f'static/sample_clothes/{t}_{i}.png', 'clothing_type':t}); \
31
+ except: pass; \
32
+ with open('static/sample_clothes_catalog.json','w') as f: json.dump(sample_catalog,f)"
33
 
34
+ # Expose Gradio
35
  EXPOSE 7860
36
 
37
+ # Healthcheck
38
+ HEALTHCHECK --interval=30s --timeout=10s CMD curl -f http://localhost:7860 || exit 1
39
+
40
  CMD ["python", "app.py"]