Skip to content

Commit

Permalink
Unify entrypoints for containers
Browse files Browse the repository at this point in the history
Signed-off-by: oguzkaganozt <[email protected]>
  • Loading branch information
oguzkaganozt committed Feb 20, 2024
1 parent 46dc8b2 commit b38a0f7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 38 deletions.
6 changes: 3 additions & 3 deletions docker/autoware-openadk/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 0 additions & 30 deletions docker/autoware-openadk/etc/dev_entrypoint.sh

This file was deleted.

34 changes: 29 additions & 5 deletions docker/autoware-openadk/etc/ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b38a0f7

Please sign in to comment.