Compare commits
14 Commits
913797e814
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c18a1e2db | ||
| ad7415f155 | |||
| 4239391ab7 | |||
| 420184e733 | |||
| 5f760e47ea | |||
| f34088a1e7 | |||
|
|
ab21b4c285 | ||
|
|
2ddbf88d8b | ||
|
|
f1d6d516d1 | ||
| 245b5325e6 | |||
|
|
44f9d1dd2a | ||
|
|
bbea59dc40 | ||
|
|
0044f602cd | ||
| 2aca9c7b55 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
/*
|
|
||||||
!/docker-compose.yaml
|
!/docker-compose.yaml
|
||||||
!/build_ros
|
!/build_ros
|
||||||
!/start.sh
|
!/start.sh
|
||||||
|
!/shell.sh
|
||||||
!/.gitignore
|
!/.gitignore
|
||||||
|
/home
|
||||||
|
|||||||
@@ -1,11 +1,27 @@
|
|||||||
ARG ROS=humble
|
ARG ROS=humble
|
||||||
FROM osrf/ros:${ROS}-desktop
|
FROM osrf/ros:${ROS}-desktop-full
|
||||||
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
|
|
||||||
|
|
||||||
ARG GID=1000
|
#SSH (First to hopefully keep keys, even on modification.)
|
||||||
ARG UID=1000
|
RUN apt-get update && apt-get install -y openssh-server && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN groupadd -f -g $GID ros
|
#OpenGL
|
||||||
RUN useradd -u $UID -g $GID -m ros
|
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}"]
|
||||||
|
|||||||
@@ -1,9 +1,39 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
groupadd -f -g $GID ros
|
if [ ! -f /home/ros/docker_image_version ]; then
|
||||||
useradd -u $UID -g $GID -m ros
|
echo "0" > /home/ros/docker_image_version
|
||||||
usermod -aG video ros
|
fi
|
||||||
usermod -aG render ros
|
|
||||||
chown -R $UID:$GID /home/ros
|
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -2,13 +2,12 @@ version: "3.2"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
ros:
|
ros:
|
||||||
|
hostname: ros
|
||||||
image: ros/custom
|
image: ros/custom
|
||||||
build:
|
build:
|
||||||
context: ./build_ros
|
context: ./build_ros
|
||||||
args:
|
args:
|
||||||
ROS: galactic #Desired ROS version
|
ROS: humble #Desired ROS version
|
||||||
UID: ${U_ID}
|
|
||||||
GID: ${G_ID}
|
|
||||||
volumes:
|
volumes:
|
||||||
- /tmp/.X11-unix:/tmp/.X11-unix:rw
|
- /tmp/.X11-unix:/tmp/.X11-unix:rw
|
||||||
- ./home:/home/ros
|
- ./home:/home/ros
|
||||||
@@ -17,11 +16,10 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- DISPLAY=$DISPLAY
|
- DISPLAY=$DISPLAY
|
||||||
- XAUTHORITY=$XAUTHORITY
|
- XAUTHORITY=$XAUTHORITY
|
||||||
- U_ID=${U_ID}
|
|
||||||
- G_ID=${G_ID}
|
|
||||||
user: ${U_ID}:${G_ID}
|
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
|
ports:
|
||||||
|
- "2222:2222"
|
||||||
#group_add:
|
#group_add:
|
||||||
# - video
|
# - video
|
||||||
# - render
|
# - render
|
||||||
|
|||||||
35
start.sh
35
start.sh
@@ -1,32 +1,53 @@
|
|||||||
#!/bin/bash
|
#!/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
|
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 build
|
||||||
sudo U_ID="$(id -u)" G_ID="$(id -g)" docker-compose up -d
|
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=()
|
hosts=()
|
||||||
|
|
||||||
while read line; do
|
while read -r line; do
|
||||||
hosts+=(`sudo docker inspect --format='{{ .Config.Hostname }}' $line`)
|
hosts+=("$(sudo docker inspect --format='{{ .Config.Hostname }}' "$line")")
|
||||||
#xhost +local:`sudo docker inspect --format='{{ .Config.Hostname }}' $line`
|
#xhost +local:`sudo docker inspect --format='{{ .Config.Hostname }}' $line`
|
||||||
done <<< "$up_result"
|
done <<< "$up_result"
|
||||||
|
|
||||||
echo "Adding to xhost:"
|
echo "Adding to xhost:"
|
||||||
for host in ${hosts[@]}; do
|
for host in "${hosts[@]}"; do
|
||||||
echo " + $host"
|
echo " + $host"
|
||||||
xhost "+local:$host"
|
xhost "+local:$host"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Attaching."
|
echo "Attaching."
|
||||||
echo "You are ready for shell access."
|
|
||||||
sudo docker-compose up
|
sudo docker-compose up
|
||||||
|
|
||||||
echo "Removing from xhost:"
|
echo "Removing from xhost:"
|
||||||
for host in ${hosts[@]}; do
|
for host in "${hosts[@]}"; do
|
||||||
echo " - $host"
|
echo " - $host"
|
||||||
xhost "-local:$host"
|
xhost "-local:$host"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
popd || exit
|
||||||
|
|||||||
Reference in New Issue
Block a user