|
| 1 | +ARG BASE_IMAGE=base |
| 2 | +FROM ros:jazzy AS base |
| 3 | + |
| 4 | +# Edit apt config for caching and update once |
| 5 | +RUN mv /etc/apt/apt.conf.d/docker-clean /etc/apt/ && \ |
| 6 | + echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' \ |
| 7 | + > /etc/apt/apt.conf.d/keep-cache && \ |
| 8 | + apt-get update |
| 9 | + |
| 10 | +################################################################################ |
| 11 | +# MARK: prepper - prep rgl dependencies |
| 12 | +################################################################################ |
| 13 | +### Core dependencies stage |
| 14 | +FROM $BASE_IMAGE AS prepper |
| 15 | + |
| 16 | +# Set working directory using standard opt path |
| 17 | +WORKDIR /opt/rgl |
| 18 | + |
| 19 | +# Copy package manifest |
| 20 | +COPY package.xml src/RGLGazeboPlugin/package.xml |
| 21 | + |
| 22 | +# Install bootstrap tools for install scripts |
| 23 | +RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ |
| 24 | + rosdep install -y \ |
| 25 | + --from-paths src \ |
| 26 | + --ignore-src |
| 27 | + |
| 28 | +################################################################################ |
| 29 | +# MARK: builder - build rgl binaries |
| 30 | +################################################################################ |
| 31 | +FROM prepper AS builder |
| 32 | + |
| 33 | +# Copy source tree |
| 34 | +COPY . src/RGLGazeboPlugin |
| 35 | + |
| 36 | +RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ |
| 37 | + colcon build |
| 38 | + |
| 39 | +################################################################################ |
| 40 | +# MARK: dancer - multi-stage for cache dancing |
| 41 | +################################################################################ |
| 42 | +FROM builder AS dancer |
| 43 | + |
| 44 | +# Copy entire build directory |
| 45 | +# RUN mkdir /dancer && \ |
| 46 | +# cp -rT build /dancer |
| 47 | + |
| 48 | +# Copy only the lib and bin directories |
| 49 | +RUN mkdir /dancer && \ |
| 50 | + cp -rT install /dancer |
| 51 | + |
| 52 | +################################################################################ |
| 53 | +# MARK: exporter - export rgl binaries and executables |
| 54 | +################################################################################ |
| 55 | +FROM scratch AS exporter |
| 56 | + |
| 57 | +COPY --from=dancer /dancer / |
0 commit comments