FROM nvidia/cuda:12.4.1-devel-ubuntu22.04 AS compile
RUN apt-get update && apt-get install -y --no-install-recommends python3 g++ ca-certificates \
    && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY cat-pov/ cat-pov/
COPY references/ references/
RUN CAT_POV_WORK=/opt/render bash cat-pov/build.sh cuda \
    && /opt/render/cat-pov-cuda --timeline /opt/render/timeline.json

FROM ubuntu:24.04
RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg python3 ca-certificates \
    && rm -rf /var/lib/apt/lists/*
COPY --from=compile /opt/render/cat-pov-cuda /opt/render/cat-pov-cuda
COPY --from=compile /opt/render/timeline.json /opt/render/timeline.json
COPY cat-pov/cloud/task.py /opt/render/task.py
COPY cat-pov/data/exposure.txt /opt/render/exposure.txt
ENV PYTHONUNBUFFERED=1
ENTRYPOINT ["python3","/opt/render/task.py"]
