Compare commits

..

14 Commits

Author SHA1 Message Date
Bastian Hofmann
3c18a1e2db Better env handling 2023-06-27 14:24:44 +02:00
ad7415f155 Added python lsp 2023-04-28 06:27:11 +02:00
4239391ab7 Changed dependencies 2023-04-20 22:22:12 +02:00
420184e733 Changes to used packages 2023-02-16 17:34:54 +01:00
5f760e47ea Migrate to ROS2 humble 2022-11-22 09:47:57 +01:00
f34088a1e7 Fixed startscript (ShellCheck.net) 2022-11-17 15:21:54 +01:00
Bastian Hofmann
ab21b4c285 Fix folder path
Added root prevention
2022-11-14 15:58:09 +01:00
Bastian Hofmann
2ddbf88d8b Merge branch 'master' of ssh://bitbucket.xitaso.com/ri/docker_ros_x11 2022-11-14 15:53:34 +01:00
Bastian Hofmann
f1d6d516d1 Additional environment vars 2022-11-14 15:47:49 +01:00
245b5325e6 Changed some starting logic, should result in better ssh access. 2022-11-14 15:41:40 +01:00
Bastian Hofmann
44f9d1dd2a Added DISPLAY to env.
Did you know echo cmd was unstable? I didn't.
2022-09-28 16:09:49 +02:00
Bastian Hofmann
bbea59dc40 Changed default permissions to root, sshd for connectivity to container. 2022-09-22 10:51:46 +02:00
Bastian Hofmann
0044f602cd Remove package index after install 2022-09-12 14:02:44 +02:00
2aca9c7b55 Hopefully final initial fixes. 2022-09-05 11:10:23 +02:00
7 changed files with 98 additions and 29 deletions

2
.env Normal file
View File

@@ -0,0 +1,2 @@
U_ID=1000
G_ID=1000

3
.gitignore vendored
View File

@@ -1,5 +1,6 @@
/*
!/docker-compose.yaml
!/build_ros
!/start.sh
!/shell.sh
!/.gitignore
/home

View File

@@ -1,11 +1,27 @@
ARG ROS=humble
FROM osrf/ros:${ROS}-desktop
RUN apt-get update && apt-get install -y ros-galactic-ros-ign-gazebo
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y xserver-xorg-video-all libgl1-mesa-glx libgl1-mesa-dri libglvnd0 libgl1 libglx0 libegl1 libxext6 libx11-6
RUN apt-get update && apt-get install -y libvulkan1 mesa-vulkan-drivers vulkan-utils mesa-utils
FROM osrf/ros:${ROS}-desktop-full
ARG GID=1000
ARG UID=1000
#SSH (First to hopefully keep keys, even on modification.)
RUN apt-get update && apt-get install -y openssh-server && rm -rf /var/lib/apt/lists/*
RUN groupadd -f -g $GID ros
RUN useradd -u $UID -g $GID -m ros
#OpenGL
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y xserver-xorg-video-all libgl1-mesa-glx libgl1-mesa-dri libglvnd0 libgl1 libglx0 libegl1 libxext6 libx11-6 && rm -rf /var/lib/apt/lists/*
#Vulkan
RUN apt-get update && apt-get install -y libvulkan1 mesa-vulkan-drivers vulkan-tools mesa-utils && rm -rf /var/lib/apt/lists/*
#Utils
RUN apt-get update && apt-get install -y gdb clang-format git ninja-build git bash-completion python3-pylsp clangd ccls && rm -rf /var/lib/apt/lists/*
#Rosdeps
RUN apt-get update && apt-get install -y ros-humble-ament-cmake ros-humble-moveit ros-humble-behaviortree-cpp-v3 ros-humble-gazebo-ros ros-humble-ros-gz-sim ros-humble-ros2-control ros-humble-gazebo-ros2-control ros-humble-ros2-controllers ros-humble-moveit-ros-control-interface && rm -rf /var/lib/apt/lists/*
RUN mkdir /run/sshd
ARG G_ID=1000
ARG U_ID=1000
RUN groupadd -f -g ${G_ID} ros
RUN useradd -u ${U_ID} -g ${G_ID} -m ros
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD ["/usr/bin/bash", "-c", "/entrypoint.sh", "${ROS_NAME}"]

View File

@@ -1,9 +1,39 @@
#!/bin/bash
groupadd -f -g $GID ros
useradd -u $UID -g $GID -m ros
usermod -aG video ros
usermod -aG render ros
chown -R $UID:$GID /home/ros
if [ ! -f /home/ros/docker_image_version ]; then
echo "0" > /home/ros/docker_image_version
fi
exec su ros -c "/ros_entrypoint.sh $@"
chsh -s /usr/bin/bash ros
if [ "0" == "$(cat /home/ros/docker_image_version)" ]; then
echo "Performing initial setup..."
cp /etc/skel/.* /home/ros
chown -R ros:ros /home/ros
su ros -c "echo 'source ~/.rosrc' >> ~/.bashrc"
echo "Modified .bashrc"
su ros -c "mkdir -p /home/ros/workspace/src"
echo "Created workspace"
su ros -c "cd /home/ros/workspace; colcon build --event-handlers console_cohesion+ --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja"
echo "Built workspace"
printf "1" > /home/ros/docker_image_version
fi
if [ ! -f /home/ros/.ssh/id_rsa ]; then
su ros -c "ssh-keygen -N '' -f /home/ros/.ssh/id_rsa"
echo "Generated SSH Keys."
fi
echo "ros:ros" | chpasswd
su ros -c "printf 'source /opt/ros/$ROS_DISTRO/setup.bash
source /home/ros/workspace/install/setup.bash
export DISPLAY=$DISPLAY
export XAUTHORITY=$XAUTHORITY' > ~/.rosrc"
echo "Ready to connect."
/usr/sbin/sshd -p 2222 -D

View File

@@ -2,13 +2,12 @@ version: "3.2"
services:
ros:
hostname: ros
image: ros/custom
build:
context: ./build_ros
args:
ROS: galactic #Desired ROS version
UID: ${U_ID}
GID: ${G_ID}
ROS: humble #Desired ROS version
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- ./home:/home/ros
@@ -17,11 +16,10 @@ services:
environment:
- DISPLAY=$DISPLAY
- XAUTHORITY=$XAUTHORITY
- U_ID=${U_ID}
- G_ID=${G_ID}
user: ${U_ID}:${G_ID}
stdin_open: true
tty: true
ports:
- "2222:2222"
#group_add:
# - video
# - render

1
shell.sh Executable file
View File

@@ -0,0 +1 @@
sudo docker-compose exec -w /home/ros ros bash

View File

@@ -1,32 +1,53 @@
#!/bin/bash
mkdir $(dirname "$0")/home
if [[ "$EUID" = 0 ]]; then
printf "Please run as user. I will invoke sudo when needed."
exit
fi
pushd "$(dirname "$0")" || exit
if [ ! -d "home" ]; then
mkdir home
fi
if [ ! -d "home/.ssh" ]; then
mkdir home/.ssh
fi
ident=$(<~/.ssh/id_rsa.pub)
grep -sqF -- "$ident" "home/.ssh/authorized_keys" || echo "$ident" >> "home/.ssh/authorized_keys"
sudo docker-compose down
echo U_ID="$(id -u)" > "$(dirname "$0")/.env"
echo G_ID="$(id -g)" >> "$(dirname "$0")/.env"
sudo U_ID="$(id -u)" G_ID="$(id -g)" docker-compose build
sudo U_ID="$(id -u)" G_ID="$(id -g)" docker-compose up -d
up_result=$(sudo docker-compose ps -q)
up_result="$(sudo docker-compose ps -q)"
hosts=()
while read line; do
hosts+=(`sudo docker inspect --format='{{ .Config.Hostname }}' $line`)
while read -r line; do
hosts+=("$(sudo docker inspect --format='{{ .Config.Hostname }}' "$line")")
#xhost +local:`sudo docker inspect --format='{{ .Config.Hostname }}' $line`
done <<< "$up_result"
echo "Adding to xhost:"
for host in ${hosts[@]}; do
for host in "${hosts[@]}"; do
echo " + $host"
xhost "+local:$host"
done
echo "Attaching."
echo "You are ready for shell access."
sudo docker-compose up
echo "Removing from xhost:"
for host in ${hosts[@]}; do
for host in "${hosts[@]}"; do
echo " - $host"
xhost "-local:$host"
done
popd || exit