Redora / Dockerfile
paulhemb's picture
Update Dockerfile
75ab3fb verified
Raw History Blame Contribute Delete
2.11 kB
FROM python:3.10-slim
# Allow custom Hugging Face model architectures (required for rt_detr_v2)
ENV HF_TRUST_REMOTE_CODE=1
WORKDIR /code
# Install system dependencies (including libpango for manim)
# --- Added for Manim's MathTex/Tex support: a LaTeX distribution + dvisvgm.
# This is the ONLY thing added to this file. cairo/pango/ffmpeg were
# already here and are why everything except LaTeX-based rendering works.
# Package list matches Manim's own documented Debian/Ubuntu requirements:
# https://docs.manim.community/en/stable/installation/linux.html
RUN apt-get update && apt-get install -y \
build-essential \
espeak-ng \
libsndfile1 \
pkg-config \
libcairo2-dev \
libpango1.0-dev \
ffmpeg \
texlive \
texlive-latex-extra \
texlive-fonts-extra \
texlive-latex-recommended \
texlive-science \
tipa \
&& rm -rf /var/lib/apt/lists/*
COPY ./requirements.txt /code/requirements.txt
# Upgrade pip, setuptools, wheel
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
# Install all Python packages (CUDA PyTorch via extra index)
# Changed index from cpu to cu124 for GPU support on T4
RUN pip install --no-cache-dir \
--extra-index-url https://download.pytorch.org/whl/cu124 \
-r /code/requirements.txt
# Ensure transformers is exactly the version we need (overrides any downgrade)
RUN pip install --no-cache-dir --force-reinstall transformers==5.13.1
# Verify transformers version
RUN python -c "import transformers; print('Transformers version:', transformers.__version__)"
# Clear any cached Hugging Face models (ensures clean download at runtime)
RUN rm -rf /root/.cache/huggingface/hub /home/user/.cache/huggingface/hub
# Pre‑download Kokoro TTS model (public, no token needed)
RUN python -c "from kokoro import KPipeline; KPipeline(lang_code='b')"
# Create a non‑root user
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
COPY --chown=user . $HOME/app
# Start the server
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]