Skip to content

Commit 2a2296c

Browse files
committed
Add fixuid as the default entrypoint.
1 parent c1ff4ed commit 2a2296c

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
@@ -118,16 +130,16 @@ RUN sudo apt-get -q update \
118130
&& sudo apt-get clean -y \
119131
&& sudo rm -rf /var/lib/apt/lists/*
120132

121-
# Actually build workspace
122-
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
123-
&& colcon build
124-
125-
RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
133+
RUN echo "if [ -f ${USER_WORKSPACE}/install/setup.bash ]; then source ${USER_WORKSPACE}/install/setup.bash; fi" >> /home/$USERNAME/.bashrc \
126134
&& echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc \
127135
&& echo "source $VIRTUAL_ENV/bin/activate" >> /home/$USERNAME/.bashrc \
128136
&& echo "\n# Ensure colcon is run in the venv\nalias colcon='python3 -m colcon'" >> /home/$USERNAME/.bashrc
129137

130-
FROM robot AS desktop
138+
139+
# Actually build workspace
140+
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
141+
&& colcon build
142+
131143

132144
ENV DEBIAN_FRONTEND=noninteractive
133145
ENV GZ_VERSION=harmonic

0 commit comments

Comments
 (0)