File size: 1,514 Bytes
e42eb20 f6e10bb e42eb20 6bcb8c6 e42eb20 f6e10bb e42eb20 f6e10bb e42eb20 f6e10bb e42eb20 f6e10bb e42eb20 f6e10bb e42eb20 f6e10bb e42eb20 f6e10bb e42eb20 f6e10bb e42eb20 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | # Use a lighter base if you don't actually need CUDA; otherwise, keep this.
FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu22.04
# 1. Install System Dependencies (Added curl, git, and build-essentials)
USER root
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
curl \
git \
sudo \
build-essential \
libssl-dev \
libffi-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 2. Create non-root user (Hugging Face requirement)
RUN adduser --disabled-password --gecos '' user
RUN mkdir -p /home/user/app && chown -R user:user /home/user/app
# Set environment variables
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONUNBUFFERED=1
WORKDIR $HOME/app
# 3. Setup Python Environment
# Using a virtual environment is lighter than Miniconda for a single-purpose bot
USER user
RUN python3 -m pip install --upgrade pip
# 4. Copy Files and Set Permissions
# Copy everything into the WORKDIR (/home/user/app)
COPY --chown=user:user . .
# 5. Install Python Requirements
# Note: Ensure 'telethon' and 'cryptography' are in reqs.txt
RUN pip install --no-cache-dir redis fastapi nest-asyncio uvicorn
RUN pip install --no-cache-dir -r reqs.txt || true
# 6. Create Persistent Directories inside WORKDIR
# Using local paths instead of /app to ensure write permissions
RUN mkdir -p sessions downloads && chmod -R 777 sessions downloads
# 7. Final Script Setup
RUN chmod +x start.sh
# Hugging Face Spaces port
EXPOSE 7860
ENTRYPOINT ["./start.sh"] |