# Use a slim version of Python runtime as a parent image FROM python:3.10.13 # Prevent Python from writing .pyc files and buffering stdout/stderr ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Install necessary system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg \ libsndfile1 \ git \ wget \ libegl1 \ libgl1 \ libgl1-mesa-glx \ libopengl0 \ libxcb-cursor0 \ libxcb-shape0 \ libxcb-randr0 \ libxcb-render0 \ libxcb-render-util0 \ libxcb-image0 \ libxcb-keysyms1 \ libxcb-glx0 \ libxkbcommon0 \ libxkbcommon-x11-0 \ libx11-xcb1 \ libxrender1 \ libxfixes3 \ libxdamage1 \ libxext6 \ libsm6 \ libx11-6 \ libxft2 \ libxinerama1 \ libxrandr2 \ libxcomposite1 \ libxcursor1 \ libxi6 \ libfontconfig1 \ libfreetype6 \ libssl3 \ libxml2 \ libxslt1.1 \ libsqlite3-0 \ zlib1g \ libopenjp2-7 \ libjpeg62-turbo \ libpng16-16 \ libtiff-dev \ libwebp7 \ poppler-utils \ libxml2-dev \ libxslt1-dev \ libgtk-3-0 \ libglib2.0-0 \ libglib2.0-data \ libice6 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Install Calibre (which includes ebook-convert) RUN wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sh /dev/stdin # Ensure that ebook-convert is available in PATH ENV PATH="/root/calibre:${PATH}" # Set working directory WORKDIR /app # Create necessary directories with proper permissions RUN mkdir -p /app/Working_files/Book \ /app/Working_files/temp_ebook \ /app/Working_files/temp \ /app/Working_files/temp_converted \ /app/cache/fontconfig \ && chmod -R 777 /app/Working_files /app/cache # Set XDG_CACHE_HOME for Fontconfig to resolve cache directory issues ENV XDG_CACHE_HOME=/app/cache # Set a writable cache directory for Hugging Face Transformers ENV HF_HOME=/app/cache RUN mkdir -p /app/cache && chmod -R 777 /app/cache # Set a writable cache directory for Numba ENV NUMBA_CACHE_DIR=/app/cache/numba_cache RUN mkdir -p /app/cache/numba_cache && chmod -R 777 /app/cache/numba_cache # Set writable Matplotlib config directory ENV MPLCONFIGDIR=/app/cache/matplotlib RUN mkdir -p $MPLCONFIGDIR && chmod -R 777 $MPLCONFIGDIR # Copy the requirements file COPY requirements.txt . # Install Python dependencies RUN pip install --upgrade pip RUN pip install --no-cache-dir --verbose -r requirements.txt # Download Gradio's frpc_linux_amd64_v0.3 to resolve share link issue RUN mkdir -p /usr/local/lib/python3.10/site-packages/gradio && \ wget -O /usr/local/lib/python3.10/site-packages/gradio/frpc_linux_amd64_v0.3 https://cdn-media.huggingface.co/frpc-gradio-0.3/frpc_linux_amd64 && \ chmod +x /usr/local/lib/python3.10/site-packages/gradio/frpc_linux_amd64_v0.3 # Download NLTK data RUN python -m nltk.downloader punkt # Copy your application files COPY app.py . # Set ENTRYPOINT and CMD ENTRYPOINT ["python", "app.py"] CMD []