Skip to content

Instantly share code, notes, and snippets.

@ardabbour
Last active June 9, 2021 21:23
Show Gist options
  • Save ardabbour/1396d444ce1e614068b4179ec232d1b4 to your computer and use it in GitHub Desktop.
Save ardabbour/1396d444ce1e614068b4179ec232d1b4 to your computer and use it in GitHub Desktop.
A starting point for ROS melodic project Dockerfiles
FROM ros:melodic
ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
# Add essential tools
RUN apt-get update && apt-get install --no-install-recommends -y \
apt-transport-https \
ca-certificates \
gnupg2 \
software-properties-common \
wget && \
rm -rf /var/lib/apt/lists/*
# Add apt source for cmake
RUN wget --quiet -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \
apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \
apt-get install kitware-archive-keyring && \
apt-key --keyring /etc/apt/trusted.gpg del C1F34CDD40CD72DA
# Add apt source for gazebo
RUN echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list && \
wget --quiet -O - https://packages.osrfoundation.org/gazebo.key | apt-key add -
# Upgrade stale packages
RUN apt-get update && \
apt-get upgrade -y && \
rm -rf /var/lib/apt/lists/*
# Install CMake
RUN apt-get update && apt-get install --no-install-recommends -y \
cmake && \
rm -rf /var/lib/apt/lists/*
# Install Gazebo
RUN apt-get update && apt-get install --no-install-recommends -y \
apt-get gazebo11 \
apt-get libgazebo11-dev && \
rm -rf /var/lib/apt/lists/*
# Install rosdep, catkin, and rosinstall
RUN apt-get update && apt-get install --no-install-recommends -y \
python-rosdep \
python-rosdep-modules \
python-catkin-tools \
python-rosinstall && \
rm -rf /var/lib/apt/lists/*
# Copy package into the container
RUN mkdir -p /opt/package_ws/src/package
COPY ./ ./opt/package_ws/src/package/
# Install dependencies
RUN cd ./package_ws && \
apt-get update && rosdep install --from-paths src --ignore-src -r -y && \
rm -rf /var/lib/apt/lists/*
# Clean up
RUN apt-get autoremove -y && \
apt-get autoclean -y && \
rm -rf /var/lib/apt/lists/*
# Build and install
RUN cd ./package_ws && \
/bin/bash -c "source /opt/ros/melodic/setup.bash && \
catkin clean --all --yes && \
catkin config --install && \
catkin build -j$(nproc) --cmake-args -DCMAKE_BUILD_TYPE=Release"
COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment