# Pudu Map GUI — fully dockerized. ONE image carries everything the GUI does:
#   web server + converter/editor backend (pillow/numpy/pyyaml)
#   goal sending (roslibpy -> robot rosbridge)
#   local /map publisher + RViz preview (ROS Jazzy + rviz2, X11 passthrough)
#   robot deploys (openssh-client/scp), ping, native file picker (zenity/tk)
# Run with host network + X11 + the host paths mounted VERBATIM (see run_docker.sh)
# so all absolute paths inside the code resolve identically in and out of docker.
FROM ros:jazzy

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
        ros-jazzy-rviz2 \
        python3-pil python3-numpy python3-yaml python3-pip \
        python3-tk zenity \
        openssh-client rsync iputils-ping psmisc \
    && rm -rf /var/lib/apt/lists/*

# roslibpy is not packaged in apt; 24.04 needs the PEP-668 override. cryptography
# is PINNED to the deb version — pip can't uninstall debian packages (no RECORD)
# and the TLS extra chain would otherwise try to upgrade it.
RUN pip3 install --no-cache-dir --break-system-packages "cryptography==41.0.7" roslibpy

# The GUI itself is volume-mounted (workstation-canonical, live-editable) — the
# image only guarantees the runtime. Fallback copy so the image also runs alone.
COPY pudu_gui.py index.html local_map_pub.py /opt/pudu_map_gui/

# rviz/relay launches source /opt/ros/jazzy/setup.bash themselves (ENV_CLEAN)
ENTRYPOINT ["/bin/bash", "-lc"]
CMD ["source /opt/ros/jazzy/setup.bash && python3 ${PUDU_GUI_DIR:-/opt/pudu_map_gui}/pudu_gui.py"]
