-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
86 lines (72 loc) · 3.06 KB
/
Dockerfile
File metadata and controls
86 lines (72 loc) · 3.06 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
# Use the official Ubuntu 24.04 image
FROM ubuntu:24.04
# Set up environment variables for non-interactive install
ENV DEBIAN_FRONTEND=noninteractive
# --- STEP 1: Install basic dependencies, XFCE/VNC, and locales (as root) ---
RUN apt-get update && apt-get install -y \
software-properties-common \
curl \
build-essential \
wget \
git \
openssh-client \
tigervnc-standalone-server \
tigervnc-common \
tigervnc-tools \
xfce4 \
xfce4-goodies \
xterm \
openbox \
dbus-x11 \
locales \
xfonts-base \
xfonts-75dpi \
xfonts-100dpi \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*
# --- STEP 2: Set up locale, add ROS 2 repo, and install ROS 2 Jazzy (as root) ---
RUN locale-gen en_US en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
ENV LANG=en_US.UTF-8
# Add ROS 2 repository and key
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null && \
apt-get update
# Install ROS 2 Jazzy (includes rviz2) and python tools
RUN apt-get install -y \
ros-jazzy-desktop \
python3-rosdep \
python3-colcon-common-extensions && \
rosdep init && \
rosdep update
# --- STEP 3: Create non-root user (as root) ---
ENV USER_NAME=user
ENV USER_PASSWORD=password
RUN useradd -m -s /bin/bash $USER_NAME
# --- Set up TigerVNC password and startup script ---
RUN mkdir -p /home/$USER_NAME/.vnc && \
echo $USER_PASSWORD | /usr/bin/vncpasswd -f > /home/$USER_NAME/.vnc/passwd && \
chmod 600 /home/$USER_NAME/.vnc/passwd
# VNC startup script - simple window manager that works
RUN echo '#!/bin/bash' > /home/$USER_NAME/.vnc/xstartup && \
echo 'unset SESSION_MANAGER' >> /home/$USER_NAME/.vnc/xstartup && \
echo 'unset DBUS_SESSION_BUS_ADDRESS' >> /home/$USER_NAME/.vnc/xstartup && \
echo 'export XKL_XMODMAP_DISABLE=1' >> /home/$USER_NAME/.vnc/xstartup && \
echo 'xsetroot -solid grey' >> /home/$USER_NAME/.vnc/xstartup && \
echo 'xterm -geometry 120x32+50+50 -ls -title "$VNCDESKTOP Desktop" &' >> /home/$USER_NAME/.vnc/xstartup && \
echo 'exec openbox-session' >> /home/$USER_NAME/.vnc/xstartup && \
chmod +x /home/$USER_NAME/.vnc/xstartup
# Change ownership of the entire .vnc directory to the user
RUN chown -R $USER_NAME:$USER_NAME /home/$USER_NAME/.vnc
# Copy and use the custom startup script (as root)
COPY start.sh /home/$USER_NAME/start.sh
RUN chmod +x /home/$USER_NAME/start.sh && chown $USER_NAME:$USER_NAME /home/$USER_NAME/start.sh
# --- STEP 4: Complete ROS setup (Switching to non-root user) ---
USER $USER_NAME
ENV HOME=/home/$USER_NAME
# Set up the shell for ROS 2
RUN echo "source /opt/ros/jazzy/setup.bash" >> $HOME/.bashrc
# Expose VNC port (default is 5901 for display :1)
EXPOSE 5901
# Start the VNC server using the custom script
CMD ["/home/user/start.sh"]