Skip to content

Commit

Permalink
Docker cleanup (autowarefoundation#1946)
Browse files Browse the repository at this point in the history
* Docker: Add truly generic docker support

Unify docker support with a new (and more generic) set of docker files.

Two main images are created:
- Base image containing an Ubuntu installation with all dependencies
- Build image containing a pre-built Autoware

When Cuda support is enabled, there is a further Base+Cuda support image.
These Dockerfiles can be used for both AArch64 and x86_64 images.

Co-authored-by: Filipe Rinaldi <filipe.rinaldi@arm.com>

* ros/.gitignore: Ignore log and coverage folders

* Autoware built using colcon instead of catkin

* Install ROS dependencies via file

* Docker: Recommend NVIDIA Docker version 2

Make it explicit in the documentation that we recommend NVIDIA Docker
v2.
  • Loading branch information
filiperinaldi authored and sgermanserrano committed Mar 13, 2019
1 parent 3ebbc7b commit b185642
Show file tree
Hide file tree
Showing 18 changed files with 624 additions and 293 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git*
ros/build*
ros/devel*
ros/install*
ros/log*
ros/coverage_*
87 changes: 0 additions & 87 deletions docker/96boards/Dockerfile.kinetic

This file was deleted.

22 changes: 0 additions & 22 deletions docker/96boards/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions docker/96boards/build.sh

This file was deleted.

35 changes: 0 additions & 35 deletions docker/96boards/run.sh

This file was deleted.

16 changes: 16 additions & 0 deletions docker/generic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG FROM_ARG
ARG ROS_DISTRO
FROM ${FROM_ARG}

ENV USERNAME autoware

# Build Autoware
COPY --chown=autoware ./ /home/$USERNAME/Autoware
RUN su -c "bash -c 'source /opt/ros/$ROS_DISTRO/setup.bash; \
cd /home/$USERNAME/Autoware/ros; \
./colcon_release'" $USERNAME
RUN echo "source /home/$USERNAME/Autoware/ros/install/local_setup.bash" >> \
/home/$USERNAME/.bashrc

COPY ./docker/generic/entrypoint.sh /tmp
ENTRYPOINT ["/tmp/entrypoint.sh"]
95 changes: 95 additions & 0 deletions docker/generic/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#
# Install ROS packages used by Autoware.
#
ARG ROS_DISTRO
FROM ros:$ROS_DISTRO

#
# Install tools and libraries required by Autoware
#
RUN apt-get update && apt-get install -y \
cmake-curses-gui \
cmake-qt-gui \
dbus-x11 \
dmz-cursor-theme \
fonts-dejavu \
gconf2 \
gnome-terminal \
gstreamer0.10-plugins-good \
language-pack-en \
libarmadillo-dev \
libcanberra-gtk-module \
libcanberra-gtk3-0 \
libcanberra-gtk3-module \
libdbus-glib-1-2 \
libgflags-dev \
libglew-dev \
libgoogle-glog-dev \
libgoogle-perftools-dev \
libgsl0-dev \
libmosquitto-dev \
libopencv-dev \
libopenni2-dev \
libpcap-dev \
libssh2-1-dev \
locales \
pulseaudio \
python-flask \
python-requests \
python3-colcon-common-extensions \
python3-pip \
python3-setuptools \
sudo \
tmux \
v4l-utils \
vim \
wget && \
pip3 install -U setuptools && \
rm -rf /var/lib/apt/lists/*

#
# Configure environmet
#

RUN update-locale LANG=en_US.UTF-8 LC_MESSAGES=POSIX

# Add user
ENV USERNAME autoware
ARG USER_ID=1000
ARG GROUP_ID=15214
ENV PULSE_SERVER /run/pulse/native

RUN groupadd --gid $GROUP_ID $USERNAME && \
useradd --gid $GROUP_ID -m $USERNAME && \
echo "$USERNAME:$USERNAME" | chpasswd && \
usermod --shell /bin/bash $USERNAME && \
usermod -aG sudo $USERNAME && \
usermod --uid $USER_ID $USERNAME && \
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME

# Startup scripts
ENV LANG="en_US.UTF-8"
RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> /etc/profile.d/ros.sh && \
# Fix for QT and X server errors
echo "export QT_X11_NO_MITSHM=1" >> /etc/profile.d/autoware.sh && \
# Set defaut language
echo "export LANG=\"en_US.UTF-8\"" >> /etc/profile.d/autoware.sh

#
# Install ROS packages used by Autoware
#
COPY ./docker/generic/dependencies /tmp/dependencies
RUN apt-get update && \
sed "s/\$ROS_DISTRO/$ROS_DISTRO/g" "/tmp/dependencies" | xargs apt-get install -y && \
rm -rf /var/lib/apt/lists/*

RUN su -c "rosdep update" autoware

# Configure terminal colors
RUN su -c "gconftool-2 --set \"/apps/gnome-terminal/profiles/Default/use_theme_background\" --type bool false" autoware && \
su -c "gconftool-2 --set \"/apps/gnome-terminal/profiles/Default/use_theme_colors\" --type bool false" autoware && \
su -c "gconftool-2 --set \"/apps/gnome-terminal/profiles/Default/background_color\" --type string \"#000000\"" autoware

COPY ./docker/generic/entrypoint.sh /tmp
ENTRYPOINT ["/tmp/entrypoint.sh"]
88 changes: 88 additions & 0 deletions docker/generic/Dockerfile.cuda
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
ARG FROM_ARG
FROM ${FROM_ARG}
USER root


# From nvidia cuda 9.0 base: https://gitlab.com/nvidia/cuda/tree/ubuntu16.04/9.0/base/Dockerfile

RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates apt-transport-https gnupg-curl && \
rm -rf /var/lib/apt/lists/* && \
NVIDIA_GPGKEY_SUM=d1be581509378368edeec8c1eb2958702feedf3bc3d17011adbf24efacce4ab5 && \
NVIDIA_GPGKEY_FPR=ae09fe4bbd223a84b2ccfce3f60f4b3d7fa2af80 && \
apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub && \
apt-key adv --export --no-emit-version -a $NVIDIA_GPGKEY_FPR | tail -n +5 > cudasign.pub && \
echo "$NVIDIA_GPGKEY_SUM cudasign.pub" | sha256sum -c --strict - && rm cudasign.pub && \
echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/cuda.list && \
echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list

ENV CUDA_VERSION 9.0.176

ENV CUDA_PKG_VERSION 9-0=$CUDA_VERSION-1
RUN apt-get update && apt-get install -y --no-install-recommends \
cuda-cudart-$CUDA_PKG_VERSION && \
ln -s cuda-9.0 /usr/local/cuda && \
rm -rf /var/lib/apt/lists/*

RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf

ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64

# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ENV NVIDIA_REQUIRE_CUDA "cuda>=9.0"


# From nvidia cuda 9.0 runtime: https://gitlab.com/nvidia/cuda/blob/ubuntu16.04/9.0/runtime/Dockerfile

ENV NCCL_VERSION 2.3.7

RUN apt-get update && apt-get install -y --no-install-recommends \
cuda-libraries-$CUDA_PKG_VERSION \
cuda-cublas-9-0=9.0.176.4-1 \
libnccl2=$NCCL_VERSION-1+cuda9.0 && \
apt-mark hold libnccl2 && \
rm -rf /var/lib/apt/lists/*

# From nvidia cuda 9.0 devel: https://gitlab.com/nvidia/cuda/blob/ubuntu16.04/9.0/devel/Dockerfile

RUN apt-get update && apt-get install -y --no-install-recommends \
cuda-libraries-dev-$CUDA_PKG_VERSION \
cuda-nvml-dev-$CUDA_PKG_VERSION \
cuda-minimal-build-$CUDA_PKG_VERSION \
cuda-command-line-tools-$CUDA_PKG_VERSION \
cuda-core-9-0=9.0.176.3-1 \
cuda-cublas-dev-9-0=9.0.176.4-1 \
libnccl-dev=$NCCL_VERSION-1+cuda9.0 && \
rm -rf /var/lib/apt/lists/*

ENV LIBRARY_PATH /usr/local/cuda/lib64/stubs

# Support for Nvidia docker v2

RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
libxau-dev \
libxdmcp-dev \
libxcb1-dev \
libxext-dev \
libx11-dev && \
rm -rf /var/lib/apt/lists/*
COPY --from=nvidia/opengl:1.0-glvnd-runtime-ubuntu16.04 \
/usr/local/lib/x86_64-linux-gnu \
/usr/lib/x86_64-linux-gnu
COPY --from=nvidia/opengl:1.0-glvnd-runtime-ubuntu16.04 \
/usr/local/share/glvnd/egl_vendor.d/10_nvidia.json \
/usr/local/share/glvnd/egl_vendor.d/10_nvidia.json
RUN echo '/usr/local/lib/x86_64-linux-gnu' >> /etc/ld.so.conf.d/glvnd.conf && \
ldconfig
RUN apt-get update
# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics

ENTRYPOINT ["/tmp/entrypoint.sh"]
Loading

0 comments on commit b185642

Please sign in to comment.