norhan12 commited on
Commit
6b154ff
·
verified ·
1 Parent(s): d29e2d6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -11
Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
  FROM python:3.10-slim
2
 
3
- # Install system dependencies
4
  RUN apt-get update && apt-get install -y \
5
  libsndfile1 \
6
  ffmpeg \
@@ -13,41 +13,47 @@ RUN apt-get update && apt-get install -y \
13
  build-essential \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- # Create non-root user
17
  RUN useradd -m appuser
18
 
19
- # Create directory structure
20
  RUN mkdir -p \
21
  /tmp/matplotlib \
22
  /tmp/fontconfig \
23
  /tmp/lhotse \
24
  /app/uploads \
25
  /app/processed_audio \
26
- /app/assets && \
 
 
27
  chown -R appuser:appuser /app /tmp/matplotlib /tmp/fontconfig /tmp/lhotse
28
 
29
- # Set working directory
30
  WORKDIR /app
31
 
32
- # Copy application files
33
  COPY --chown=appuser:appuser . .
34
 
35
- # Set environment variables
36
  ENV MPLCONFIGDIR=/tmp/matplotlib \
37
  FONTCONFIG_PATH=/tmp/fontconfig \
38
  LHOTSE_CACHE_DIR=/tmp/lhotse \
39
  HF_HUB_ENABLE_HF_TRANSFER=1 \
40
  PYTHONUNBUFFERED=1
41
 
42
- # Install Python dependencies
43
  USER appuser
44
  RUN pip install --upgrade pip && \
45
  pip install --no-cache-dir -r requirements.txt && \
46
  python -m spacy download en_core_web_sm && \
47
  pip check
48
 
49
- # Expose port
 
 
 
 
50
  EXPOSE 7860
51
 
52
- # This is the CRITICAL FIX:
53
- CMD ["python", "app.py"]
 
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. انشاء يوزر غير روت
17
  RUN useradd -m appuser
18
 
19
+ # 3. إنشاء فولدرات مع الصلاحيات
20
  RUN mkdir -p \
21
  /tmp/matplotlib \
22
  /tmp/fontconfig \
23
  /tmp/lhotse \
24
  /app/uploads \
25
  /app/processed_audio \
26
+ /app/assets \
27
+ /app/temp_files \
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"]