diff --git a/docker/etc/entrypoint.sh b/docker/etc/entrypoint.sh new file mode 100644 index 0000000000..a118d39147 --- /dev/null +++ b/docker/etc/entrypoint.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# Source ROS2 and Autoware +source "/opt/ros/$ROS_DISTRO/setup.bash" +source /opt/autoware/setup.bash + +# Check if VNC is enabled +if [ "$VNC_ENABLED" = "true" ]; then + + # Start VNC server + echo "Starting VNC server..." + vncserver :1 -auth $HOME/.Xauthority -geometry 1024x768 -depth 16 -pixelformat rgb565 >/dev/null 2>&1 + VNC_RESULT=$? + + if [ $VNC_RESULT -ne 0 ]; then + echo "Failed to start VNC server (exit code: $VNC_RESULT)" + exit $VNC_RESULT + fi + + sleep 2 + + # Start NoVNC + echo "Starting NoVNC..." + websockify --daemon --web=/usr/share/novnc/ --cert=/etc/ssl/certs/novnc.crt --key=/etc/ssl/private/novnc.key 6080 localhost:5901 + + # Get local IP address (works on Linux) + LOCAL_IP=$(hostname -I | awk '{print $1}') + NOVNC_URL="${LOCAL_IP}:6080" + + # Configure ngrok if NGROK_AUTHTOKEN is set + if [ -n "$NGROK_AUTHTOKEN" ]; then + echo "Starting ngrok..." + ngrok config add-authtoken $NGROK_AUTHTOKEN + + # Start ngrok tunnel for NoVNC + ngrok http --url=$NGROK_URL 6080 --log=stdout >ngrok.log & + + NOVNC_URL=https://$NGROK_URL + fi + + # Start Rviz + rviz2 -d /autoware/simulation/scenario_simulator.rviz + + # Print message + echo -e "\033[32m-------------------------------------------------------------------------\033[0m" + echo -e "Note: In order to access VNC and NoVNC on localhost, you need to expose ports 5901 and 6080 to the outside world respectively." + echo -e "\033[32mVNC server is running and accessible at localhost:5901 via VNC viewer\033[0m" + echo -e "\033[32mNoVNC web interface available at $NOVNC_URL/vnc.html via web browser\033[0m" + echo -e "\033[32m-------------------------------------------------------------------------\033[0m" +fi + +# Run command +exec "$@" diff --git a/docker/planning-control/entrypoint.sh b/docker/planning-control/entrypoint.sh deleted file mode 100644 index 286db2474f..0000000000 --- a/docker/planning-control/entrypoint.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC1090,SC1091 - -source "/opt/ros/$ROS_DISTRO/setup.bash" -source /opt/autoware/setup.bash -exec "$@" diff --git a/docker/planning-control/fail/Dockerfile b/docker/planning-control/fail/Dockerfile index dcc708f8af..a1c583bfd1 100644 --- a/docker/planning-control/fail/Dockerfile +++ b/docker/planning-control/fail/Dockerfile @@ -4,6 +4,6 @@ FROM ghcr.io/autowarefoundation/autoware:universe AS planning-control-fail COPY docker/planning-control/fail/fail_scenario.launch.xml /opt/autoware/share/autoware_launch/config/planning/scenario_planning/lane_driving/behavior_planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/static_obstacle_avoidance.param.yaml # Copy entrypoint script -COPY docker/planning-control/entrypoint.sh /entrypoint.sh +COPY docker/etc/entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker/planning-control/pass/Dockerfile b/docker/planning-control/pass/Dockerfile index 8ff64a3893..69a0d43333 100644 --- a/docker/planning-control/pass/Dockerfile +++ b/docker/planning-control/pass/Dockerfile @@ -4,6 +4,6 @@ FROM ghcr.io/autowarefoundation/autoware:universe AS planning-control-pass COPY docker/planning-control/pass/pass_scenario.launch.xml /opt/autoware/share/autoware_launch/config/planning/scenario_planning/lane_driving/behavior_planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/static_obstacle_avoidance.param.yaml # Copy entrypoint script -COPY docker/planning-control/entrypoint.sh /entrypoint.sh +COPY docker/etc/entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker/simulator-visualizer/Dockerfile b/docker/simulator-visualizer/Dockerfile index 1e4d66aca2..692e982752 100644 --- a/docker/simulator-visualizer/Dockerfile +++ b/docker/simulator-visualizer/Dockerfile @@ -83,7 +83,7 @@ RUN curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | \ EXPOSE 5900 6080 # Copy entrypoint script -COPY docker/simulator-visualizer/entrypoint.sh /entrypoint.sh +COPY docker/etc/entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker/simulator-visualizer/entrypoint.sh b/docker/simulator-visualizer/entrypoint.sh deleted file mode 100644 index b42395425b..0000000000 --- a/docker/simulator-visualizer/entrypoint.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -# Source ROS2 and Autoware -source "/opt/ros/$ROS_DISTRO/setup.bash" -source /opt/autoware/setup.bash - -# Start VNC server -echo "Starting VNC server..." -vncserver :1 -auth $HOME/.Xauthority -geometry 1024x768 -depth 16 -pixelformat rgb565 >/dev/null 2>&1 -VNC_RESULT=$? - -if [ $VNC_RESULT -ne 0 ]; then - echo "Failed to start VNC server (exit code: $VNC_RESULT)" - exit $VNC_RESULT -fi - -sleep 2 - -# Start NoVNC -echo "Starting NoVNC..." -websockify --daemon --web=/usr/share/novnc/ --cert=/etc/ssl/certs/novnc.crt --key=/etc/ssl/private/novnc.key 6080 localhost:5901 - -# Get local IP address (works on Linux) -LOCAL_IP=$(hostname -I | awk '{print $1}') -NOVNC_URL="${LOCAL_IP}:6080" - -# Configure ngrok if NGROK_AUTHTOKEN is set -if [ -n "$NGROK_AUTHTOKEN" ]; then - echo "Starting ngrok..." - ngrok config add-authtoken $NGROK_AUTHTOKEN - - # Start ngrok tunnel for NoVNC - ngrok http --url=$NGROK_URL 6080 --log=stdout >ngrok.log & - - NOVNC_URL=https://$NGROK_URL -fi - -# Start Rviz -rviz2 -d /autoware/simulation/scenario_simulator.rviz - -# Print message -echo -e "\033[32m-------------------------------------------------------------------------\033[0m" -echo -e "Note: In order to access VNC and NoVNC on localhost, you need to expose ports 5901 and 6080 to the outside world respectively." -echo -e "\033[32mVNC server is running and accessible at localhost:5901 via VNC viewer\033[0m" -echo -e "\033[32mNoVNC web interface available at $NOVNC_URL/vnc.html via web browser\033[0m" -echo -e "\033[32m-------------------------------------------------------------------------\033[0m" - -# Run command -exec "$@"