# Use the official Python 3.11 slim image as the base FROM python:3.11-slim # Set environment variables ENV VENV_PATH="/venv" ENV PATH="$VENV_PATH/bin:$PATH" # Install system dependencies RUN apt-get update && \ apt-get install -y --no-install-recommends \ ffmpeg \ espeak-ng \ wget \ python3-venv && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # Create and activate virtual environment, then install audiblez RUN python -m venv $VENV_PATH && \ $VENV_PATH/bin/pip install --no-cache-dir --upgrade pip && \ $VENV_PATH/bin/pip install --no-cache-dir audiblez # Download Kokoro model and voices RUN mkdir -p /root/.local/share/audiblez/ && \ wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/kokoro-v0_19.onnx -P /root/.local/share/audiblez/ && \ wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/voices.json -P /root/.local/share/audiblez/ # Set the working directory to /ebooks WORKDIR /ebooks # Create the /m4b directory RUN mkdir -p /m4b # Copy all .m4b output to /m4b after conversion using audiblez from venv CMD for book in *.epub; do $VENV_PATH/bin/audiblez "$book" -v af_aoede; done && cp *.m4b /m4b/