-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile to simplify build process (#40)
* Add package.xml file * Omit linters * Add missing rosdistro keys for gazebo depends * Add .dockerignore file * Simplify * Add Dockerfile * Add docker build command to README * Lint Dockerfile * Separate RobotecGPULidar project to external directory * Add expected project tree info * Only extract so file from install path to demonstrate cmake issues * Use cache mounts for src folder to demonstrate cmake issues * Make source folder read only to demonstrate cmake issues * Reenable build as expected by relaxing normal build conventions to demonstrate cmake issues * Do not hardcode CMAKE_INSTALL_PREFIX * Make project files read-only. This commit changes RGL download directory from SOURCE_DIR to BINARY_DIR * Update .dockerignore to exempt dir external * Simplify builder stage now that cmake behaves * Simplify and copy install path --------- Co-authored-by: Mateusz Szczygielski <mateusz.szczygielski@robotec.ai>
- Loading branch information
Showing
4 changed files
with
100 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Ignore everything by default | ||
* | ||
|
||
# First-order allow exception for select directories | ||
!/external | ||
!/lidar_patterns | ||
!/RGLServerPlugin | ||
!/RGLVisualize | ||
|
||
# First-order allow exception for select files | ||
!/CMakeLists.txt | ||
!/package.xml |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
ARG BASE_IMAGE=base | ||
FROM ros:jazzy AS base | ||
|
||
# Edit apt config for caching and update once | ||
RUN mv /etc/apt/apt.conf.d/docker-clean /etc/apt/ && \ | ||
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' \ | ||
> /etc/apt/apt.conf.d/keep-cache && \ | ||
apt-get update | ||
|
||
################################################################################ | ||
# MARK: prepper - prep rgl dependencies | ||
################################################################################ | ||
### Core dependencies stage | ||
FROM $BASE_IMAGE AS prepper | ||
|
||
# Set working directory using standard opt path | ||
WORKDIR /opt/rgl | ||
|
||
# Copy package manifest | ||
COPY package.xml src/RGLGazeboPlugin/package.xml | ||
|
||
# Install bootstrap tools for install scripts | ||
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ | ||
rosdep install -y \ | ||
--from-paths src \ | ||
--ignore-src | ||
|
||
################################################################################ | ||
# MARK: builder - build rgl binaries | ||
################################################################################ | ||
FROM prepper AS builder | ||
|
||
# Copy source tree | ||
COPY . src/RGLGazeboPlugin | ||
|
||
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ | ||
colcon build | ||
|
||
################################################################################ | ||
# MARK: dancer - multi-stage for cache dancing | ||
################################################################################ | ||
FROM builder AS dancer | ||
|
||
# Copy entire build directory | ||
# RUN mkdir /dancer && \ | ||
# cp -rT build /dancer | ||
|
||
# Copy only the lib and bin directories | ||
RUN mkdir /dancer && \ | ||
cp -rT install /dancer | ||
|
||
################################################################################ | ||
# MARK: exporter - export rgl binaries and executables | ||
################################################################################ | ||
FROM scratch AS exporter | ||
|
||
COPY --from=dancer /dancer / |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>RGLGazeboPlugin</name> | ||
<version>0.1.2</version> | ||
<description>RGL Gazebo Plugin</description> | ||
<maintainer email="mateusz.szczygielski@robotec.ai">Mateusz Szczygielski</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
|
||
<depend>gz_cmake_vendor</depend> | ||
<depend>gz_gui_vendor</depend> | ||
<depend>gz_msgs_vendor</depend> | ||
<depend>gz_plugin_vendor</depend> | ||
<depend>gz_rendering_vendor</depend> | ||
<depend>gz_sim_vendor</depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |