# Derive from Ubuntu Bionic
FROM ubuntu:bionic

# Configuration variables
ENV ROS_VERSION_NAME dashing

# Setup timezone
RUN echo 'Etc/UTC' > /etc/timezone && \
    ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
    apt-get update && apt-get install -q -y tzdata \
    && rm -rf /var/lib/apt/lists/*

# Add ROS 2 repositories
RUN apt-get update && apt-get install -q -y \
    curl \
    gnupg2 \
    lsb-release \
    && curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add - \
    && sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list' \
    && apt-get remove -y -q \
        curl \
        gnupg2 \
        lsb-release \
    && rm -rf /var/lib/apt/lists/*

# Install bare bones ROS Installation
RUN apt-get update && apt-get install -q -y \
    ros-$ROS_VERSION_NAME-ros-base python3-colcon-common-extensions \
    && rm -rf /var/lib/apt/lists/*

# Add source command to root user bashrc
RUN echo "source /opt/ros/$ROS_VERSION_NAME/setup.bash" >> ~/.bashrc
