B4869 commited on
Commit
dfdb5f4
·
1 Parent(s): a3a6e6d

bug fix again

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -22
Dockerfile CHANGED
@@ -1,35 +1,19 @@
1
- # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
- # Hugging Face Spaces best practices for Docker
3
-
4
- FROM python:3.9
5
-
6
- # สร้าง non-root user เพื่อความปลอดภัย
7
- RUN useradd -m -u 1000 user
8
- USER user
9
- ENV PATH="/home/user/.local/bin:$PATH"
10
-
11
- # ตั้งค่า cache directory สำหรับ Hugging Face models
12
- # ใช้ /tmp เพราะมี space มากกว่า default location (~/.cache/)
13
- ENV HF_HOME="/home/user/.cache/huggingface"
14
-
15
- # รับ HF_TOKEN จาก build args สำหรับ gated models
16
- ARG HF_TOKEN
17
- ENV HF_TOKEN=$HF_TOKEN
18
 
19
  WORKDIR /app
20
 
21
- # Copy requirements และ install dependencies
22
  COPY --chown=user ./requirements.txt requirements.txt
23
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
24
 
 
25
  COPY --chown=user ./download_model.py download_model.py
26
- RUN python download_model.py
27
 
28
  # Copy application code
29
  COPY --chown=user . /app
30
 
31
- # Expose port 7860 (default port สำหรับ Hugging Face Spaces)
32
  EXPOSE 7860
33
 
34
- # Run Flask app with Gunicorn (production WSGI server)
35
- CMD ["gunicorn", "app:app", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120"]
 
 
1
+ # ... (ส่วนบนเหมือนเดิม) ...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # Copy requirements และ install
6
  COPY --chown=user ./requirements.txt requirements.txt
7
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
8
 
9
+ # Copy script มาวาง (แต่ยังไม่รัน)
10
  COPY --chown=user ./download_model.py download_model.py
 
11
 
12
  # Copy application code
13
  COPY --chown=user . /app
14
 
 
15
  EXPOSE 7860
16
 
17
+ # แก้ไข CMD: สั่งให้โหลด model ก่อน แล้วค่อยรัน server
18
+ # การใช้ && จะทำให้ถ้า download พัง server จะไม่รัน (ซึ่งดีแล้ว)
19
+ CMD ["/bin/bash", "-c", "python download_model.py && gunicorn app:app --bind 0.0.0.0:7860 --workers 1 --timeout 120"]