Skip to content

Commit

Permalink
Fortress backport - Add Dockerfile to simplify build process (Robotec…
Browse files Browse the repository at this point in the history
…AI#41)

* 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

* Backport to ROS Iron and Gazebo Fortress

* Separate RobotecGPULidar project to external directory (RobotecAI#42)

* Separate RobotecGPULidar project to external directory

* Add expected project tree info

* Do not hardcode CMAKE_INSTALL_PREFIX

* Make project files read-only.
This commit changes RGL download directory from SOURCE_DIR to BINARY_DIR

* Fix brackets

* 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

* Update .dockerignore to exempt dir external

* Simplify builder stage
now that cmake behaves

* Simplify and copy install path

---------

Co-authored-by: Mateusz Szczygielski <[email protected]>
  • Loading branch information
ruffsl and msz-rai authored Jul 17, 2024
1 parent 070ae3a commit 35f1977
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
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
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
ARG BASE_IMAGE=base
FROM ros:iron 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 /
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ Key features:
export IGN_GUI_PLUGIN_PATH=`pwd`/RGLGuiPlugin:$IGN_GUI_PLUGIN_PATH
```
### Building from source

#### Docker
```shell
docker build \
--target=exporter \
--output=install .
```

#### Manual
```shell
mkdir build
cd build
Expand Down
21 changes: 21 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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="[email protected]">Mateusz Szczygielski</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>ignition-gazebo6</depend>
<depend>ignition-gui6</depend>
<depend>ignition-msgs8</depend>
<depend>ignition-plugin</depend>
<depend>ignition-rendering6</depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>

0 comments on commit 35f1977

Please sign in to comment.