ALI7ADEL commited on
Commit
08bb757
·
verified ·
1 Parent(s): 71c3369

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -20
Dockerfile CHANGED
@@ -1,36 +1,44 @@
1
- # Use an official Python runtime as a parent image
2
  FROM python:3.10-slim
3
 
4
- # Set environment variables
5
- ENV PYTHONDONTWRITEBYTECODE 1
6
- ENV PYTHONUNBUFFERED 1
7
-
8
- # Install system dependencies including Node.js for yt-dlp JS challenge solver
9
- RUN apt-get update && apt-get install -y \
10
  ffmpeg \
 
11
  git \
12
- nodejs \
13
- npm \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- # Set work directory
 
 
 
 
 
17
  WORKDIR /app
18
 
19
- # Install Python dependencies
20
  COPY requirements.txt .
21
  RUN pip install --no-cache-dir -r requirements.txt
22
 
23
- # Install yt-dlp with its default extras which includes yt-dlp-ejs (the EJS challenge solver)
24
- RUN pip install -U "yt-dlp[default]"
 
 
 
 
 
 
 
25
 
26
- # Pre-fetch the EJS challenge solver scripts from GitHub so they're baked into the image
27
- # This avoids needing to download them at runtime on every cold start
28
- RUN yt-dlp --js-runtimes node --remote-components ejs:github --simulate "https://www.youtube.com/watch?v=dQw4w9WgXcQ" || true
29
 
30
- # Copy the rest of the application
31
  COPY . .
32
 
33
- # Hugging Face Spaces expects the app to run on port 7860
34
- EXPOSE 7860
 
35
 
36
- CMD ["python", "run.py", "server"]
 
 
1
+ # 1. اختيار النسخة الأساسية
2
  FROM python:3.10-slim
3
 
4
+ # 2. تسطيب برامج النظام (ffmpeg للتعامل مع الصوت و curl لتحميل Node.js)
5
+ RUN apt-get update && apt-get install -y --no-install-recommends \
 
 
 
 
6
  ffmpeg \
7
+ curl \
8
  git \
 
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
+ # 3. تسطيب Node.js 20 (مهم جداً عشان حل شفرات يوتيوب)
12
+ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
13
+ && apt-get install -y nodejs \
14
+ && rm -rf /var/lib/apt/lists/*
15
+
16
+ # 4. تجهيز فولدر المشروع
17
  WORKDIR /app
18
 
19
+ # 5. تسطيب مكتبات بايثون
20
  COPY requirements.txt .
21
  RUN pip install --no-cache-dir -r requirements.txt
22
 
23
+ # 6. تحميل وبناء سيرفر bgutil (خبير فك الشفرات)
24
+ ARG BGUTIL_VERSION=1.3.1
25
+ RUN git clone --depth 1 --branch ${BGUTIL_VERSION} \
26
+ https://github.com/Brainicism/bgutil-ytdlp-pot-provider.git \
27
+ /opt/bgutil-provider \
28
+ && cd /opt/bgutil-provider/server \
29
+ && npm ci \
30
+ && npx tsc \
31
+ && echo "✅ bgutil POT server compiled successfully"
32
 
33
+ # 7. تسطيب الـ Plugin اللي بيربط yt-dlp بالسيرفر اللي فوق
34
+ RUN pip install --no-cache-dir "bgutil-ytdlp-pot-provider==${BGUTIL_VERSION}"
 
35
 
36
+ # 8. نسخ باقي ملفات المشروع
37
  COPY . .
38
 
39
+ # 9. تضبيط الصلاحيات عشان Hugging Face (مهم جداً عشان السيرفر ميدي لكش Error)
40
+ RUN chown -R 1000:1000 /app /opt/bgutil-provider
41
+ USER 1000
42
 
43
+ # 10. أمر تشغيل السيرفر الأساسي
44
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]