DarkMo0o commited on
Commit
9eff8a5
·
verified ·
1 Parent(s): 5edb40c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -24
Dockerfile CHANGED
@@ -1,32 +1,30 @@
1
- FROM python:3.10-slim
2
-
3
- # تعيين متغيرات البيئة
4
- ENV PYTHONUNBUFFERED=1 \
5
- PYTHONDONTWRITEBYTECODE=1 \
6
- PIP_NO_CACHE_DIR=1 \
7
- PIP_DISABLE_PIP_VERSION_CHECK=1
8
-
9
- # تثبيت المكتبات الأساسية
10
- RUN apt-get update && apt-get install -y \
11
- build-essential \
12
- curl \
13
- && rm -rf /var/lib/apt/lists/*
14
 
 
15
  WORKDIR /workspace
16
 
17
- # نسخ وتثبيت المتطلبات
 
 
 
 
18
  COPY requirements.txt .
19
- RUN pip install --no-cache-dir -r requirements.txt
20
 
21
- # نسخ الكود
22
- COPY app.py .
 
23
 
24
- # تحميل النموذج مسبقاً لتسريع البدء
25
- RUN python -c "from transformers import AutoTokenizer, AutoModelForSeq2SeqLM; \
26
- AutoTokenizer.from_pretrained('facebook/nllb-200-distilled-600M'); \
27
- AutoModelForSeq2SeqLM.from_pretrained('facebook/nllb-200-distilled-600M')"
28
 
29
- EXPOSE 7860
 
30
 
31
- # تشغيل بدون workers متعددة لتجنب مشاكل HuggingFace
32
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.11-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
 
 
 
 
 
 
 
7
 
8
+ # Set the working directory
9
  WORKDIR /workspace
10
 
11
+ # Install system dependencies
12
+ RUN apt-get update && apt-get install -y --no-install-recommends \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+ # Copy requirements first (to leverage Docker caching)
16
  COPY requirements.txt .
 
17
 
18
+ # Upgrade pip and install Python dependencies
19
+ RUN pip install --no-cache-dir --upgrade pip \
20
+ && pip install --no-cache-dir -r requirements.txt
21
 
22
+ # Copy the rest of the application files
23
+ COPY . .
 
 
24
 
25
+ # Expose port (HF Spaces use 7860 by default – flask here uses 5005)
26
+ EXPOSE 5005
27
 
28
+ # Start the server
29
+ # Note: We use uvicorn (ASGI interface) to run the Flask app via ASGI handler
30
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "5005"]