FROM python:3.14-slim AS builder

# Install the system-level dependencies onto the builder
RUN apt-get update && apt-get install -y --no-install-recommends \
   povray povray-includes ffmpeg imagemagick librsvg2-bin


FROM python:3.14-slim

# Copy only what is needed from the builder
COPY --from=builder /usr/bin/povray /usr/bin/povray
COPY --from=builder /usr/bin/ffmpeg /usr/bin/ffmpeg
COPY --from=builder /usr/bin/convert /usr/bin/convert
COPY --from=builder /usr/bin/rsvg-convert /usr/bin/rsvg-convert

# Then install only the runtime dependencies those need
# first 6 are for POV-Ray; libavdevice is for ffmpeg
RUN apt-get update && apt-get install -y --no-install-recommends \
    libsdl1.2debian \
    libopenexr-3-1-30 \
    libtiff6 \
    libpng16-16t64 \
    libboost-thread1.83.0 \
    libavdevice61 \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Finally install the kinoje scripts and modules
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY bin ./bin
COPY src ./src

RUN mkdir /mnt/host
ENV PATH="/usr/src/app/bin:${PATH}"
WORKDIR /mnt/host
