-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
110 lines (87 loc) · 2.77 KB
/
Dockerfile
File metadata and controls
110 lines (87 loc) · 2.77 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
ARG ROS_DISTRO=jazzy
FROM ros:${ROS_DISTRO}-ros-base AS base
ENV ROS_DISTRO=${ROS_DISTRO}
# Create a non-root user
ARG USERNAME=ros
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG USER_PASSWORD=ros
# Disable dpkg/gdebi interactive dialogs
ENV DEBIAN_FRONTEND=noninteractive
SHELL ["/bin/bash", "-c"]
# Delete existing user if it exists
RUN if getent passwd ${USER_UID}; then \
userdel -r $(getent passwd ${USER_UID} | cut -d: -f1); \
fi
# Delete existing group if it exists
RUN if getent group ${USER_GID}; then \
groupdel $(getent group ${USER_GID} | cut -d: -f1); \
fi
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& usermod -aG sudo,dialout,plugdev,video $USERNAME \
&& echo "$USERNAME:$USER_PASSWORD" | chpasswd \
&& mkdir /home/$USERNAME/.config && chown $USER_UID:$USER_GID /home/$USERNAME/.config
# Set up sudo
RUN apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& rm -rf /var/lib/apt/lists/*
# Install essential packages
RUN apt-get update && \
apt-get install -y --no-install-recommends \
# === Basic utilities === #
vim \
wget \
git \
unzip \
iputils-ping \
net-tools \
# === Build tools === #
build-essential \
cmake \
# === Python tools === #
pip \
python3-venv \
python3-flake8 \
python3-rosdep \
python3-setuptools \
python3-vcstool \
python3-colcon-common-extensions \
# === XRDP desktop === #
xfce4 \
xterm \
xfce4-terminal \
xorgxrdp \
xrdp \
dbus-x11 \
xfonts-base
FROM base AS workspace
ENV ROS_DISTRO=${ROS_DISTRO}
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=all
# Install additional packages from workspace.packages
COPY ./workspace.packages ./
RUN apt-get update && \
bash -lc "sed \"s/\\\${ROS_DISTRO}/${ROS_DISTRO}/g\" workspace.packages | xargs apt-get install -y --no-install-recommends"
# Symlink python3 to python
RUN ln -s /usr/bin/python3 /usr/bin/python
USER $USERNAME
# Expose VNC port
EXPOSE 3389/tcp
RUN mkdir -p /home/ros/ros2_ws/src
WORKDIR /home/ros/ros2_ws
# Clone repositories
COPY ./workspace.repos ./
RUN vcs import src < workspace.repos
# Install dependencies using rosdep
RUN source /opt/ros/$ROS_DISTRO/setup.bash \
&& rosdep update \
&& rosdep install --ignore-src --from-paths ./src -y -r
# Build the workspace
COPY ./Makefile ./
RUN source /opt/ros/$ROS_DISTRO/setup.bash \
&& make build
# Source ROS and workspace setup files in .bashrc
RUN printf "\nsource /opt/ros/$ROS_DISTRO/setup.bash\nsource ~/ros2_ws/install/setup.bash\nsource ~/ros2_ws/src/ros2_so101/scripts/ros_aliases.sh\n" >> ~/.bashrc