From 9c0e297b844cc6cd35ed617810b638b80d62d60e Mon Sep 17 00:00:00 2001 From: dologan <66838084+ologandavid@users.noreply.github.com> Date: Fri, 10 Nov 2023 11:37:37 -0500 Subject: [PATCH] Docker Support, IPOPT, Coinbrew Version Update to 3.14 (#408) * Update Setup with ipopt 3.14 * Add Dockerfile * Update Dockerfile --------- Co-authored-by: jrenaf --- docker/Dockerfile | 131 +++++++++++++++++++++++++++++++++++++++++ external/setup_deps.sh | 6 +- 2 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 docker/Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..ad50dc6ae --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,131 @@ +############################################# +# Created from template ros.dockerfile.jinja +############################################# + +########################################### +# Base image +########################################### +FROM ubuntu:20.04 AS base + +ENV DEBIAN_FRONTEND=noninteractive + +# Install language +RUN apt-get update && apt-get install -y \ + locales \ + && locale-gen en_US.UTF-8 \ + && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 \ + && rm -rf /var/lib/apt/lists/* +ENV LANG en_US.UTF-8 + +# Install timezone +RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime \ + && export DEBIAN_FRONTEND=noninteractive \ + && apt-get update \ + && apt-get install -y tzdata \ + && dpkg-reconfigure --frontend noninteractive tzdata \ + && rm -rf /var/lib/apt/lists/* + +########################################### +# ROS image +########################################### +FROM base AS ros + +# Install ROS +RUN apt-get update && apt-get install -y \ + curl \ + dirmngr \ + gnupg2 \ + lsb-release \ + sudo \ + && apt-get upgrade -y \ + && sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' \ + && curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add - \ + && apt-get update && apt-get install -y \ + ros-noetic-desktop-full \ + && apt-get upgrade libignition-math4 -y \ + && rm -rf /var/lib/apt/lists/* + +# Setup environment +ENV LD_LIBRARY_PATH=/opt/ros/noetic/lib +ENV ROS_DISTRO=noetic +ENV ROS_ROOT=/opt/ros/noetic/share/ros +ENV ROS_PACKAGE_PATH=/opt/ros/noetic/share +ENV ROS_MASTER_URI=http://localhost:11311 +ENV ROS_PYTHON_VERSION= +ENV ROS_VERSION=1 +ENV PATH=/opt/ros/noetic/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +ENV ROSLISP_PACKAGE_DIRECTORIES= +ENV PYTHONPATH=/opt/ros/noetic/lib/python3.8/dist-packages +ENV PKG_CONFIG_PATH=/opt/ros/noetic/lib/pkgconfig +ENV ROS_ETC_DIR=/opt/ros/noetic/etc/ros +ENV CMAKE_PREFIX_PATH=/opt/ros/noetic +ENV DEBIAN_FRONTEND= + +########################################### +# Develop image +########################################### +FROM ros AS dev + +ENV DEBIAN_FRONTEND=noninteractive +# Install dev tools +RUN apt-get update && apt-get install -y \ + python3-rosdep \ + python3-rosinstall \ + python3-rosinstall-generator \ + python3-wstool \ + python3-pip \ + python3-pep8 \ + python3-autopep8 \ + pylint \ + build-essential \ + bash-completion \ + git \ + vim \ + python3-catkin-tools \ + && rm -rf /var/lib/apt/lists/* \ + && rosdep init || echo "rosdep already initialized" + +ARG USERNAME=ros +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# Create a non-root user +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ + # [Optional] Add sudo support for the non-root user + && apt-get update \ + && apt-get install -y sudo git-core bash-completion \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ + && chmod 0440 /etc/sudoers.d/$USERNAME \ + # Cleanup + && rm -rf /var/lib/apt/lists/* \ + && echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc +ENV DEBIAN_FRONTEND= + +########################################### +# ADD SSH into Docker Container +########################################### + + +######################################### +# Set up auto-source of workspace for ros user +ARG WORKSPACE +RUN echo "if [ -f ${WORKSPACE}/devel/setup.bash ]; then source ${WORKSPACE}/devel/setup.bash; fi" >> /home/ros/.bashrc + + +ENV CATKIN_WS = /home/catkin_ws +ENV SDK = /home/catkin_ws/src +RUN mkdir -p $CATKIN_WS/src + +RUN /bin/bash -c "source /opt/ros/${ROS_DISTRO}/setup.bash; catkin init;" +WORKDIR $SDK +RUN git clone https://github.com/robomechanics/quad-sdk.git + +# ENV QUAD_SDK = /root/catkin_ws/src/quad-sdk +# WORKDIR $QUAD_SDK +# RUN git checkout devel + +# ADD coinhsl /home/catkin_ws/src/quad-sdk/external/ipopt/coinhsl + + + diff --git a/external/setup_deps.sh b/external/setup_deps.sh index 7bb41e208..8cc2e89be 100755 --- a/external/setup_deps.sh +++ b/external/setup_deps.sh @@ -14,9 +14,9 @@ then fi mkdir coinbrew cd coinbrew -wget https://raw.githubusercontent.com/coin-or/coinbrew/v1.0/coinbrew +wget https://raw.githubusercontent.com/coin-or/coinbrew/v2.0/coinbrew chmod u+x coinbrew -./coinbrew fetch Ipopt@3.13 --no-prompt +./coinbrew fetch Ipopt --no-prompt cd .. if [ -d "./coinhsl" ] then @@ -26,7 +26,7 @@ else echo "Warning: HSL not found." fi cd coinbrew -./coinbrew build Ipopt --latest-release --tests none --prefix=/usr/local +./coinbrew build Ipopt --latest-release --tests none --prefix=/usr/local --no-prompt cd ../.. # Setup and build for rbdl