Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile to simplify build process #40

Merged
merged 21 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore everything by default
*

# First-order allow exception for select directories
!/CMakeLists.txt
!/RGLServerPlugin
!/RGLVisualize
!/lidar_patterns
!/package.xml
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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 build/RGLGazeboPlugin/RGLServerPlugin/*.so /dancer/ && \
ruffsl marked this conversation as resolved.
Show resolved Hide resolved
cp build/RGLGazeboPlugin/RGLVisualize/*.so /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 GZ_GUI_PLUGIN_PATH=`pwd`/RGLGuiPlugin:$GZ_GUI_PLUGIN_PATH
```
### Building from source

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

#### Manual
```shell
mkdir build
cd build
Expand Down
22 changes: 22 additions & 0 deletions package.xml
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>