Skip to content

Commit b38a0f7

Browse files
committed
Unify entrypoints for containers
Signed-off-by: oguzkaganozt <oguzkaganozt@gmail.com>
1 parent 46dc8b2 commit b38a0f7

File tree

3 files changed

+32
-38
lines changed

3 files changed

+32
-38
lines changed

docker/autoware-openadk/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ RUN --mount=type=ssh \
9999
WORKDIR /workspace
100100

101101
# Create entrypoint
102-
COPY docker/autoware-openadk/etc/dev_entrypoint.sh /dev_entrypoint.sh
103-
RUN chmod +x /dev_entrypoint.sh
104-
ENTRYPOINT ["/dev_entrypoint.sh"]
102+
COPY docker/autoware-openadk/etc/ros_entrypoint.sh /ros_entrypoint.sh
103+
RUN chmod +x /ros_entrypoint.sh
104+
ENTRYPOINT ["/ros_entrypoint.sh"]
105105
CMD ["/bin/bash"]
106106

107107
FROM base as runtime

docker/autoware-openadk/etc/dev_entrypoint.sh

-30
This file was deleted.
+29-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
11
#!/usr/bin/env bash
22
# shellcheck disable=SC1090,SC1091
3-
set -e
43

5-
# hadolint ignore=SC1090
6-
source "/opt/ros/$ROS_DISTRO/setup.bash"
7-
source /autoware/install/setup.bash
8-
exec "$@"
4+
# Get the user ID and group ID of the local user
5+
USER_ID=${LOCAL_UID}
6+
USER_NAME=${LOCAL_USER}
7+
GROUP_ID=${LOCAL_GID}
8+
GROUP_NAME=${LOCAL_GROUP}
9+
10+
# Check if any of the variables are empty
11+
if [[ -z $USER_ID || -z $USER_NAME || -z $GROUP_ID || -z $GROUP_NAME ]]; then
12+
source "/opt/ros/$ROS_DISTRO/setup.bash"
13+
source /autoware/install/setup.bash
14+
exec "$@"
15+
else
16+
echo "Starting with user: $USER_NAME >> UID $USER_ID, GID: $GROUP_ID"
17+
18+
# Create group and user with GID/UID
19+
groupadd -g "$GROUP_ID" "$GROUP_NAME"
20+
useradd -u "$USER_ID" -g "$GROUP_ID" -s /bin/bash -m -d /home/"$USER_NAME" "$USER_NAME"
21+
22+
# Add sudo privileges to the user
23+
echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers
24+
25+
# Source ROS2
26+
# hadolint ignore=SC1090
27+
source "/opt/ros/$ROS_DISTRO/setup.bash"
28+
source /autoware/install/setup.bash
29+
30+
# Execute the command as the user
31+
exec /usr/sbin/gosu "$USER_NAME" "$@"
32+
fi

0 commit comments

Comments
 (0)