Skip to content

Commit 7ebe1cf

Browse files
committed
Add fixuid as the default entrypoint.
1 parent 86f394e commit 7ebe1cf

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

.docker/Dockerfile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ RUN apt-get -q update \
3939
&& rm -rf /var/lib/apt/lists/*
4040

4141
# This stage includes
42+
# - Adding the non-root user to sudoers
43+
# - Installing and configuring fixuid
4244
# - Switching to the non-root user
4345
# - Copying 'blue' source from this repo into the non-root user's workspace
4446
# - Installing blue deps using pip, apt and rosdep
@@ -50,7 +52,7 @@ FROM ci AS robot
5052

5153
#
5254
# Ubuntu 24.04 "Noble", which is used as the base image for
53-
# jazzy and rolling images, now includes a user "ubuntu" at UID 1000
55+
# jazzy and rolling images, now includes a "built-in" user "ubuntu" at UID 1000
5456
ARG USERNAME=ubuntu
5557
ARG USER_UID=1000
5658
ARG USER_GID=$USER_UID
@@ -60,6 +62,16 @@ RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
6062
&& usermod -a -G dialout $USERNAME \
6163
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc
6264

65+
# Install fixuid
66+
RUN wget -O - https://github.com/boxboat/fixuid/releases/download/v0.6.0/fixuid-0.6.0-linux-amd64.tar.gz | tar -C /usr/local/bin -xzf - && \
67+
chown root:root /usr/local/bin/fixuid && \
68+
chmod 4755 /usr/local/bin/fixuid && \
69+
mkdir -p /etc/fixuid && \
70+
printf "user: ${USERNAME}\ngroup: ${USERNAME}\n" > /etc/fixuid/config.yml
71+
72+
ENTRYPOINT ["fixuid", "-q"]
73+
CMD ["/bin/bash"]
74+
6375
ENV DEBIAN_FRONTEND=noninteractive
6476

6577
# Switch to the non-root user for the rest of the installation
@@ -137,16 +149,16 @@ RUN sudo apt-get -q update \
137149
&& sudo apt-get clean -y \
138150
&& sudo rm -rf /var/lib/apt/lists/*
139151

140-
# Actually build workspace
141-
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
142-
&& colcon build
143-
144-
RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
152+
RUN echo "if [ -f ${USER_WORKSPACE}/install/setup.bash ]; then source ${USER_WORKSPACE}/install/setup.bash; fi" >> /home/$USERNAME/.bashrc \
145153
&& echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc \
146154
&& echo "source $VIRTUAL_ENV/bin/activate" >> /home/$USERNAME/.bashrc \
147155
&& echo "\n# Ensure colcon is run in the venv\nalias colcon='python3 -m colcon'" >> /home/$USERNAME/.bashrc
148156

149-
FROM robot AS desktop
157+
158+
# Actually build workspace
159+
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
160+
&& colcon build
161+
150162

151163
ENV DEBIAN_FRONTEND=noninteractive
152164
ENV GZ_VERSION=harmonic

0 commit comments

Comments
 (0)