Spaces:
Running
Running
| # HuggingFace Spaces Dockerfile - Bot + API Only | |
| # Dashboard is deployed separately on Vercel | |
| FROM ubuntu:22.04 | |
| # Set timezone | |
| ENV TZ=Asia/Kolkata | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | |
| # Install Python 3.11 and required system packages | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| software-properties-common \ | |
| ca-certificates \ | |
| gnupg2 \ | |
| gdb \ | |
| git \ | |
| gcc \ | |
| g++ \ | |
| make \ | |
| ffmpeg \ | |
| mediainfo \ | |
| curl \ | |
| wget \ | |
| tesseract-ocr\ | |
| neofetch \ | |
| dnsutils \ | |
| bash \ | |
| && mkdir -p /usr/share/keyrings \ | |
| && curl -fsSL https://keyserver.ubuntu.com/pks/lookup?op=get\&search=0xF23C5A6CF475977595C89F51BA6932366A755776 | gpg --dearmor -o /usr/share/keyrings/deadsnakes.gpg \ | |
| && echo "deb [signed-by=/usr/share/keyrings/deadsnakes.gpg] http://ppa.launchpad.net/deadsnakes/ppa/ubuntu jammy main" > /etc/apt/sources.list.d/deadsnakes-ppa.list \ | |
| && apt-get update && apt-get install -y --no-install-recommends \ | |
| python3.11 \ | |
| python3.11-dev \ | |
| python3.11-venv \ | |
| python3.11-distutils \ | |
| && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11 \ | |
| && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 \ | |
| && update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 \ | |
| && apt-get clean && rm -rf /var/lib/apt/lists/* | |
| # Create a non-root user | |
| RUN useradd -m user | |
| # Set working directory | |
| WORKDIR /app | |
| # Upgrade pip and install base packages | |
| ENV PIP_ROOT_USER_ACTION=ignore | |
| RUN pip install --upgrade pip | |
| RUN pip install --no-cache-dir uvicorn fastapi httpx | |
| # Copy startup scripts | |
| COPY startup-hf-init.sh /app/startup-hf-init.sh | |
| COPY start_hf.py /app/start_hf.py | |
| RUN chmod +x /app/startup-hf-init.sh | |
| # Set environment | |
| ENV PYTHONPATH="${PYTHONPATH}:/app/repo" | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # Expose HuggingFace port (mandatory) | |
| EXPOSE 7860 | |
| ENV PORT=7860 | |
| # Change ownership | |
| RUN chown -R user:user /app | |
| # Switch to non-root user | |
| USER user | |
| # Run initialization script (clones repo, starts bot + API) | |
| CMD ["/app/startup-hf-init.sh"] | |