diff --git a/docker/autoware-openadk/Dockerfile b/docker/autoware-openadk/Dockerfile index d1088557a38..b03fe1630a2 100644 --- a/docker/autoware-openadk/Dockerfile +++ b/docker/autoware-openadk/Dockerfile @@ -99,9 +99,9 @@ RUN --mount=type=ssh \ WORKDIR /workspace # Create entrypoint -COPY docker/autoware-openadk/etc/dev_entrypoint.sh /dev_entrypoint.sh -RUN chmod +x /dev_entrypoint.sh -ENTRYPOINT ["/dev_entrypoint.sh"] +COPY docker/autoware-openadk/etc/ros_entrypoint.sh /ros_entrypoint.sh +RUN chmod +x /ros_entrypoint.sh +ENTRYPOINT ["/ros_entrypoint.sh"] CMD ["/bin/bash"] FROM base as runtime diff --git a/docker/autoware-openadk/etc/dev_entrypoint.sh b/docker/autoware-openadk/etc/dev_entrypoint.sh deleted file mode 100644 index c83dc0e8fd8..00000000000 --- a/docker/autoware-openadk/etc/dev_entrypoint.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC1090,SC1091 - -# Get the user ID and group ID of the local user -USER_ID=${LOCAL_UID} -USER_NAME=${LOCAL_USER} -GROUP_ID=${LOCAL_GID} -GROUP_NAME=${LOCAL_GROUP} - -# Check if any of the variables are empty -if [[ -z $USER_ID || -z $USER_NAME || -z $GROUP_ID || -z $GROUP_NAME ]]; then - exec "$@" -else - echo "Starting with user: $USER_NAME >> UID $USER_ID, GID: $GROUP_ID" - - # Create group and user with GID/UID - groupadd -g "$GROUP_ID" "$GROUP_NAME" - useradd -u "$USER_ID" -g "$GROUP_ID" -s /bin/bash -m -d /home/"$USER_NAME" "$USER_NAME" - - # Add sudo privileges to the user - echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers - - # Source ROS2 - # hadolint ignore=SC1090 - source "/opt/ros/$ROS_DISTRO/setup.bash" - source /autoware/install/setup.bash - - # Execute the command as the user - exec /usr/sbin/gosu "$USER_NAME" "$@" -fi diff --git a/docker/autoware-openadk/etc/ros_entrypoint.sh b/docker/autoware-openadk/etc/ros_entrypoint.sh index c620967c9ad..cbe45ef3bdb 100644 --- a/docker/autoware-openadk/etc/ros_entrypoint.sh +++ b/docker/autoware-openadk/etc/ros_entrypoint.sh @@ -1,8 +1,32 @@ #!/usr/bin/env bash # shellcheck disable=SC1090,SC1091 -set -e -# hadolint ignore=SC1090 -source "/opt/ros/$ROS_DISTRO/setup.bash" -source /autoware/install/setup.bash -exec "$@" +# Get the user ID and group ID of the local user +USER_ID=${LOCAL_UID} +USER_NAME=${LOCAL_USER} +GROUP_ID=${LOCAL_GID} +GROUP_NAME=${LOCAL_GROUP} + +# Check if any of the variables are empty +if [[ -z $USER_ID || -z $USER_NAME || -z $GROUP_ID || -z $GROUP_NAME ]]; then + source "/opt/ros/$ROS_DISTRO/setup.bash" + source /autoware/install/setup.bash + exec "$@" +else + echo "Starting with user: $USER_NAME >> UID $USER_ID, GID: $GROUP_ID" + + # Create group and user with GID/UID + groupadd -g "$GROUP_ID" "$GROUP_NAME" + useradd -u "$USER_ID" -g "$GROUP_ID" -s /bin/bash -m -d /home/"$USER_NAME" "$USER_NAME" + + # Add sudo privileges to the user + echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers + + # Source ROS2 + # hadolint ignore=SC1090 + source "/opt/ros/$ROS_DISTRO/setup.bash" + source /autoware/install/setup.bash + + # Execute the command as the user + exec /usr/sbin/gosu "$USER_NAME" "$@" +fi