-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa50225
commit 76e3b01
Showing
4 changed files
with
28 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,35 @@ | ||
# ROS distribution to use | ||
ARG ROS_DISTRO=iron | ||
|
||
######################################## | ||
# Base ROS 2 development image, # | ||
# Forked from TurtleBot3 Simulation # | ||
# sea-bass/turtlebot3_behavior_demos # | ||
######################################## | ||
FROM ros:${ROS_DISTRO} as base | ||
FROM ros:${ROS_DISTRO} as dev | ||
ENV ROS_DISTRO=${ROS_DISTRO} | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
SHELL ["/bin/bash", "-c"] | ||
|
||
# Install basic apt packages | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
git curl libcanberra-gtk-module libcanberra-gtk3-module fuse3 libfuse2 libqt5svg5-dev \ | ||
python3-pip python3-opencv python3-tk python3-pyqt5.qtwebengine | ||
|
||
# Install additional Python modules | ||
RUN pip3 install matplotlib transforms3d | ||
|
||
# Use Cyclone DDS as middleware | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
ros-${ROS_DISTRO}-rmw-cyclonedds-cpp | ||
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp | ||
|
||
# Create Colcon workspace with external dependencies | ||
ENV BASE_WS=/ws | ||
RUN mkdir -p $BASE_WS/src | ||
WORKDIR $BASE_WS/src | ||
COPY dependencies.repos . | ||
RUN vcs import < dependencies.repos | ||
# Create Colcon workspace with the project and its deps | ||
ENV WS=/ws | ||
ENV PROJ_SRC=${WS}/src/naoqi_driver2 | ||
COPY . $PROJ_SRC | ||
WORKDIR $WS/src | ||
RUN apt install -y git python3-vcstool | ||
RUN vcs import < $PROJ_SRC/dependencies.repos | ||
|
||
# Build the base Colcon workspace, installing dependencies first. | ||
WORKDIR $BASE_WS | ||
WORKDIR $WS | ||
RUN source /opt/ros/${ROS_DISTRO}/setup.bash \ | ||
&& apt-get update -y \ | ||
&& rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} -y \ | ||
&& colcon build --symlink-install | ||
|
||
# Remove display warnings | ||
RUN mkdir /tmp/runtime-root | ||
ENV XDG_RUNTIME_DIR "/tmp/runtime-root" | ||
RUN chmod -R 0700 /tmp/runtime-root | ||
ENV NO_AT_BRIDGE 1 | ||
|
||
# Set up the entrypoint | ||
WORKDIR $BASE_WS | ||
COPY ./docker/entrypoint.sh / | ||
ENTRYPOINT [ "/entrypoint.sh" ] | ||
|
||
########################################### | ||
# Overlay Image with robot-specific deps # | ||
########################################### | ||
FROM base AS overlay | ||
|
||
# Create an overlay Colcon workspace | ||
ENV OVERLAY_WS=/overlay_ws | ||
RUN mkdir -p $OVERLAY_WS/src | ||
WORKDIR $OVERLAY_WS | ||
COPY . ./src/naoqi_driver2/ | ||
RUN source $BASE_WS/install/setup.bash \ | ||
&& rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} -y --include-eol-distros | ||
|
||
############################################ | ||
# Production image has everything compiled # | ||
############################################ | ||
FROM overlay AS production | ||
RUN colcon build --symlink-install | ||
|
||
##################### | ||
# Development Image # | ||
##################### | ||
FROM overlay as dev | ||
|
||
# Dev container arguments | ||
ARG USERNAME=devuser | ||
ARG UID=1000 | ||
ARG GID=${UID} | ||
&& apt-get update -y \ | ||
&& rosdep update \ | ||
&& rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} -y | ||
|
||
# Install extra tools for development | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
gdb gdbserver nano libgmock-dev | ||
|
||
# Create new user and home directory | ||
RUN groupadd --gid $GID $USERNAME \ | ||
&& useradd --uid ${GID} --gid ${UID} --create-home ${USERNAME} \ | ||
&& echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \ | ||
&& chmod 0440 /etc/sudoers.d/${USERNAME} \ | ||
&& mkdir -p /home/${USERNAME} \ | ||
&& chown -R ${UID}:${GID} /home/${USERNAME} | ||
|
||
# Set the ownership of the overlay workspace to the new user | ||
RUN chown -R ${UID}:${GID} $OVERLAY_WS/ | ||
# Expect to mount the source code from the host. | ||
VOLUME $PROJ_SRC | ||
|
||
# Set the user and source entrypoint in the user's .bashrc file | ||
USER ${USERNAME} | ||
RUN echo "source /entrypoint.sh" >> /home/${USERNAME}/.bashrc | ||
# Every bash instance should source the entrypoint | ||
RUN echo "source ${PROJ_SRC}/docker/entrypoint.sh" >> /root/.bashrc | ||
SHELL [ "/bin/bash", "-c" ] | ||
ENTRYPOINT [ "/bin/bash" ] | ||
|
||
##################### | ||
# Development Image # | ||
##################### | ||
FROM dev as dev-prebuilt | ||
RUN colcon build --symlink-install | ||
RUN colcon build --symlink-install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters