alphanet06/processor2
0
1# Optimized Dockerfile for N_m3u8DL-RE with FastAPI file server.2FROM mcr.microsoft.com/dotnet/runtime:8.0-bookworm-slim3 4# Set environment variables5ENV DEBIAN_FRONTEND=noninteractive \6 TZ=UTC \7 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=18 9# Create user as required by Hugging Face Spaces 10RUN useradd -m -u 1000 user11 12# Install system dependencies in a single layer13RUN apt-get update && apt-get install -y --no-install-recommends \14 wget \15 curl \16 unzip \17 ca-certificates \18 ffmpeg \19 python3 \20 python3-pip \21 && rm -rf /var/lib/apt/lists/* \22 && apt-get clean23 24# Download and install Bento4 tools (mp4decrypt, mp4info)25RUN cd /tmp \26 && wget -q "https://www.bok.net/Bento4/binaries/Bento4-SDK-1-6-0-641.x86_64-unknown-linux.zip" \27 && unzip -j "Bento4-SDK-1-6-0-641.x86_64-unknown-linux.zip" \28 'Bento4-SDK-1-6-0-641.x86_64-unknown-linux/bin/mp4decrypt' \29 'Bento4-SDK-1-6-0-641.x86_64-unknown-linux/bin/mp4info' \30 -d /usr/local/bin/ \31 && chmod +x /usr/local/bin/mp4decrypt /usr/local/bin/mp4info \32 && rm -f "Bento4-SDK-1-6-0-641.x86_64-unknown-linux.zip" \33 && cd /34 35# Download and install N_m3u8DL-RE36RUN cd /tmp \37 && wget -q "https://github.com/nilaoda/N_m3u8DL-RE/releases/download/v0.3.0-beta/N_m3u8DL-RE_v0.3.0-beta_linux-x64_20241203.tar.gz" \38 && tar -xzf "N_m3u8DL-RE_v0.3.0-beta_linux-x64_20241203.tar.gz" \39 && mv N_m3u8DL-RE /usr/local/bin/N_m3u8DL-RE \40 && chmod +x /usr/local/bin/N_m3u8DL-RE \41 && rm -f "N_m3u8DL-RE_v0.3.0-beta_linux-x64_20241203.tar.gz" \42 && cd /43 44# Pre-create writable Logs directory for N_m3u8DL-RE45RUN mkdir -p /usr/local/bin/Logs && chown -R user:user /usr/local/bin/Logs46 47# Set working directory48WORKDIR /app49 50# Copy requirements and install Python dependencies with --break-system-packages51# This is safe in Docker containers where we control the entire environment52COPY requirements.txt .53RUN pip3 install --no-cache-dir --break-system-packages -r requirements.txt54 55# Create directory structure for organized downloads56RUN mkdir -p stream \57 && chown -R user:user /app58 59# Copy authentication files (required for Google Drive integration)60# These files must be committed to git and will be copied into the container61COPY --chown=user credentials.json .62COPY --chown=user settings.yaml .63COPY --chown=user client_secrets.json .64 65# Copy application files66COPY --chown=user app.py .67 68# Switch to non-root user69USER user70 71# Set user environment variables72ENV HOME=/home/user \73 PATH=/home/user/.local/bin:$PATH74 75# Expose port for FastAPI server76EXPOSE 786077 78# Start FastAPI server.79CMD ["python3", "/app/app.py"]80 