norhan12 commited on
Commit
e1c55d7
·
verified ·
1 Parent(s): fa88373

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -11
Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
  FROM python:3.10-slim
2
 
3
- # 1. تثبيت dependencies النظامية
4
  RUN apt-get update && apt-get install -y \
5
  libsndfile1 \
6
  ffmpeg \
@@ -13,10 +13,10 @@ RUN apt-get update && apt-get install -y \
13
  build-essential \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- # 2. انشاء يوزر غير روت
17
  RUN useradd -m appuser
18
 
19
- # 3. إنشاء فولدرات مع الصلاحيات
20
  RUN mkdir -p \
21
  /tmp/matplotlib \
22
  /tmp/fontconfig \
@@ -28,32 +28,33 @@ RUN mkdir -p \
28
  /app/static/outputs && \
29
  chown -R appuser:appuser /app /tmp/matplotlib /tmp/fontconfig /tmp/lhotse
30
 
31
- # 4. تعيين دليل العمل
32
  WORKDIR /app
33
 
34
- # 5. نسخ ملفات التطبيق مع الصلاحيات
35
  COPY --chown=appuser:appuser . .
36
 
37
- # 6. ضبط environment variables
38
  ENV MPLCONFIGDIR=/tmp/matplotlib \
39
  FONTCONFIG_PATH=/tmp/fontconfig \
40
  LHOTSE_CACHE_DIR=/tmp/lhotse \
41
  HF_HUB_ENABLE_HF_TRANSFER=1 \
42
- PYTHONUNBUFFERED=1
 
43
 
44
- # 7. تثبيت Python dependencies
45
  USER appuser
46
  RUN pip install --upgrade pip && \
47
  pip install --no-cache-dir -r requirements.txt && \
48
  python -m spacy download en_core_web_sm && \
49
  pip check
50
 
51
- # 8. تعيين Healthcheck (اختياري)
52
  HEALTHCHECK --interval=30s --timeout=10s \
53
  CMD curl -f http://localhost:7860/ || exit 1
54
 
55
- # 9. فتح البورت 7860 (عشان نقدر نستخدم API من برة الكونتينر)
56
  EXPOSE 7860
57
 
58
- # 10. تشغيل التطبيق بـ uvicorn بدل python app.py (FastAPI أفضل بالـ uvicorn)
59
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.10-slim
2
 
3
+ # 1. تثبيت dependencies النظامية المطلوبة
4
  RUN apt-get update && apt-get install -y \
5
  libsndfile1 \
6
  ffmpeg \
 
13
  build-essential \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
+ # 2. إنشاء مستخدم غير root
17
  RUN useradd -m appuser
18
 
19
+ # 3. إنشاء المجلدات المطلوبة مع تعيين الصلاحيات
20
  RUN mkdir -p \
21
  /tmp/matplotlib \
22
  /tmp/fontconfig \
 
28
  /app/static/outputs && \
29
  chown -R appuser:appuser /app /tmp/matplotlib /tmp/fontconfig /tmp/lhotse
30
 
31
+ # 4. تعيين مجلد العمل
32
  WORKDIR /app
33
 
34
+ # 5. نسخ ملفات التطبيق إلى المجلد داخل الكونتينر مع تعيين صلاحيات اليوزر
35
  COPY --chown=appuser:appuser . .
36
 
37
+ # 6. ضبط متغيرات البيئة
38
  ENV MPLCONFIGDIR=/tmp/matplotlib \
39
  FONTCONFIG_PATH=/tmp/fontconfig \
40
  LHOTSE_CACHE_DIR=/tmp/lhotse \
41
  HF_HUB_ENABLE_HF_TRANSFER=1 \
42
+ PYTHONUNBUFFERED=1 \
43
+ BASE_URL=http://localhost:7860/static/outputs
44
 
45
+ # 7. تثبيت بايثون وابديت pip وتحميل dependencies من requirements.txt
46
  USER appuser
47
  RUN pip install --upgrade pip && \
48
  pip install --no-cache-dir -r requirements.txt && \
49
  python -m spacy download en_core_web_sm && \
50
  pip check
51
 
52
+ # 8. تعيين healthcheck (اختياري)
53
  HEALTHCHECK --interval=30s --timeout=10s \
54
  CMD curl -f http://localhost:7860/ || exit 1
55
 
56
+ # 9. فتح البورت 7860 داخل الكونتينر
57
  EXPOSE 7860
58
 
59
+ # 10. تشغيل التطبيق باستخدام uvicorn
60
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]