-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile-humble
58 lines (47 loc) · 1.83 KB
/
Dockerfile-humble
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Use the official ROS humble desktop image
FROM osrf/ros:humble-desktop
# Arguments
ARG USER_NAME=user
ARG USER_PASSWORD
ARG USER_UID=1000
ARG USER_GID=1000
# Create a user with USER_NAME and give sudo privileges
RUN groupadd -g $USER_GID $USER_NAME && \
useradd -m -s /bin/bash -u $USER_UID -g $USER_GID $USER_NAME && \
usermod -aG dialout $USER_NAME && \
usermod -aG video $USER_NAME && \
if [ -n "$USER_PASSWORD" ]; then \
echo "$USER_NAME:$USER_PASSWORD" | chpasswd && \
echo "$USER_NAME ALL=(ALL) ALL" >> /etc/sudoers.d/$USER_NAME && \
chmod 0440 /etc/sudoers.d/$USER_NAME; \
else \
echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USER_NAME && \
chmod 0440 /etc/sudoers.d/$USER_NAME; \
fi
# Install the required packages
RUN apt-get update && apt-get install -y \
python3-pip \
nano
# Copy the requirements.txt file
COPY requirements.txt /tmp/requirements.txt
# Install Python packages
RUN pip3 install -r /tmp/requirements.txt
# Set the user
USER $USER_NAME
# Set the working directory
WORKDIR /home/$USER_NAME
# Copy the ros_ws/src directory
COPY --chown=$USER_NAME:$USER_NAME ros_ws/src /home/$USER_NAME/ros_ws/src
# Build the package
RUN /bin/bash -c "source /opt/ros/$ROS_DISTRO/setup.bash && \
cd /home/$USER_NAME/ros_ws && \
rosdep update && \
rosdep install --from-paths src --ignore-src -r -y && \
colcon build --symlink-install"
# Set the environment variables
RUN echo "\n# Set the environment variables" >> ~/.bashrc && \
echo "export PATH=/home/$USER_NAME/.local/bin:\$PATH" >> ~/.bashrc && \
echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.bashrc && \
echo "source /home/$USER_NAME/ros_ws/install/local_setup.bash" >> ~/.bashrc
# Set the entrypoint
CMD ["/bin/bash"]