ros2-vim/Dockerfile
2024-06-05 12:12:29 +02:00

152 lines
5.5 KiB
Docker

FROM osrf/ros:iron-desktop-full AS base-ros-nvim
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
&& apt-get install -y \
gdb \
gdbserver \
ripgrep \
ninja-build \
gettext \
cmake \
unzip \
curl \
clang-format \
xclip \
wl-clipboard \
breeze \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& NODE_MAJOR=20 \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt update \
&& apt-get remove nodejs \
&& apt-get install nodejs \
&& git clone https://github.com/neovim/neovim.git \
&& cd neovim && git checkout stable && make CMAKE_BUILD_TYPE=RelWithDebInfo \
&& sudo make install \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
FROM base-ros-nvim AS base-ros-nvim-graphics
ARG ROS_DISTR=iron
ENV ROS_DISTR=$ROS_DISTR
ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
RUN apt-get update \
#&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
&& apt-get install -y \
software-properties-common \
#&& add-apt-repository -y ppa:inivation-ppa/inivation \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
&& apt-get install -y \
libgl1-mesa-dri \
libgl1-mesa-glx \
mesa-utils \
mesa-utils-extra \
python3-pip \
python3-venv \
avahi-daemon \
avahi-utils \
libnss-mdns \
iputils-ping \
sudo \
wget \
#dv-processing \
#dv-runtime-dev \
libserial-dev \
nlohmann-json3-dev \
ros-${ROS_DISTR}-rqt-tf-tree \
ros-${ROS_DISTR}-apriltag \
ros-${ROS_DISTR}-plotjuggler-ros \
ros-${ROS_DISTR}-tf-transformations \
ros-${ROS_DISTR}-topic-tools \
ros-${ROS_DISTR}-rviz-2d-overlay-plugins \
ros-${ROS_DISTR}-simple-launch \
ros-${ROS_DISTR}-slider-publisher \ # used for gripper tests
pre-commit \
# && pip3 install transforms3d \
# && rosdep install --from-paths /ros2_underlay/src -y --ignore-src \
# && rosdep install --from paths /ros2/src -y --ignore-src \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
FROM base-ros-nvim-graphics AS individual
ARG USERNAME=ros-user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN userdel -r ubuntu; \
groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
&& chmod 0440 /etc/sudoers.d/$USERNAME
USER ${USERNAME}
ENV TERM xterm-256color
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.1/zsh-in-docker.sh)" -- \
-p https://github.com/zsh-users/zsh-autosuggestions \
-p git \
-t "" \
-a 'fpath+=$HOME/.zsh/pure' \
-a 'autoload -U promptinit; promptinit' \
-a 'prompt pure' \
-a "export TERM=xterm-256color" \
-a "zstyle ':prompt:pure:path' color 075" \
-a "zstyle ':prompt:pure:prompt:success' color 214" \
-a "zstyle ':prompt:pure:user' color 119" \
-a "zstyle ':prompt:pure:host' color 119" \
-a "ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=161'" \
-a 'PATH=$PATH:$HOME/.local/bin' \
-a 'export HISTFILE=/zsh_history/.zsh_history' \
-a 'export TERM=xterm-256color' \
-a 'export COLORTERM=truecolor' \
&& mkdir -p "$HOME/.zsh" \
&& git clone https://github.com/sindresorhus/pure.git "$HOME/.zsh/pure" \
&& echo "source /opt/ros/$ROS_DISTR/setup.zsh" >> /home/$USERNAME/.zshrc \
# && pip3 install yapf pre-commit ruff \
&& git clone https://github.com/HippoCampusRobotics/hippo_core.git "$HOME/hippo_core" \
&& ls $HOME/hippo_core/hippo_common/scripts \
&& $HOME/hippo_core/hippo_common/scripts/install_scripts.sh \
&& sudo wget https://hippocampusrobotics.github.io/docs/_downloads/6055b3168d4f0a8cd764ebc481280219/ros-iron-px4-msgs_2.0.1-0jammy_amd64.deb \
# && sudo wget https://hippocampusrobotics.github.io/docs/_downloads/286cb880b68d2c4b6c6d9e6730fab199/ros-jazzy-px4-msgs_2.0.1-0noble_amd64.deb \
# && sudo apt-get install ./ros-${ROS_DISTR}-px4-msgs_2.0.1-0noble_amd64.deb \
&& sudo apt-get install ./ros-${ROS_DISTR}-px4-msgs_2.0.1-0jammy_amd64.deb \
&& sudo apt install asciinema \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*
USER root
RUN mkdir /zsh_history \
&& touch /zsh_history/.zsh_history \
&& chown -R $USERNAME /zsh_history
RUN mkdir -p /home/$USERNAME/.cache/pre-commit \
&& chown -R $USERNAME /home/$USERNAME/.cache/pre-commit
RUN mkdir -p /home/$USERNAME/.local/bin \
&& chown -R $USERNAME /home/$USERNAME/.local/bin
ADD ros2-vim/nvim /home/$USERNAME/.config/nvim
RUN chown -R $USERNAME /home/$USERNAME/
USER ${USERNAME}
RUN nvim --headless "+Lazy! sync" +qa
RUN nvim --headless +"MasonInstall lua-language-server clangd python-lsp-server yaml-language-server yapf" +q
WORKDIR /home/$USERNAME
USER root
ADD ros2-vim/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
RUN chown $USERNAME /entrypoint.sh
USER ${USERNAME}
# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog
CMD [ "/usr/bin/zsh"]