|
| 1 | +# syntax=docker/dockerfile:1.4 |
| 2 | +# Build with |
| 3 | +# TODO: Not use root! |
| 4 | +# Add cache for apt update.xº |
| 5 | +ARG image_base=337955887028.dkr.ecr.eu-central-1.amazonaws.com/amd64:galactic-1.4.4 |
| 6 | + |
| 7 | +ARG registry=registry.klepsydra.io/repository |
| 8 | +ARG board=amd64 |
| 9 | +ARG osrelease=focal |
| 10 | + |
| 11 | +FROM $image_base as system_dep |
| 12 | +ENV BUILD_MODE=Release |
| 13 | + |
| 14 | +USER root |
| 15 | + |
| 16 | +# Install kpe dependencies. VPN required. |
| 17 | +# COPY public.gpg.key /tmp/public.gpg.key |
| 18 | + |
| 19 | +RUN <<EOF |
| 20 | +# echo "deb https://${registry}/${board}/ ${osrelease} main" >> /etc/apt/sources.list.d/klepsydra.list |
| 21 | +# apt-key add /tmp/public.gpg.key |
| 22 | +# rm /tmp/public.gpg.key |
| 23 | +# apt update |
| 24 | + |
| 25 | +pip3 config set global.extra-index-url https://registry.klepsydra.io/repository/kpe-pypi/simple |
| 26 | +pip3 install kpsr-codegen |
| 27 | +EOF |
| 28 | + |
| 29 | +RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts |
| 30 | + |
| 31 | +FROM system_dep as kpe-core |
| 32 | +ENV KPE_CORE_TAG=v7.11.0 |
| 33 | +RUN --mount=type=ssh git clone --branch ${KPE_CORE_TAG} --recurse-submodules git@github.com:klepsydra-technologies/kpe-core |
| 34 | + |
| 35 | +RUN --mount=type=cache,target=/home/kpsruser/.ccache <<EOF |
| 36 | +cd /home/kpsruser/kpe-core |
| 37 | +# Patch to make it work. |
| 38 | +sed -i 's/set(_SPDLOG_VERSION "1.5")/set(_SPDLOG_VERSION "1.5.0")/g' CMakeLists.txt |
| 39 | +mkdir build |
| 40 | +cd build |
| 41 | +cmake -DKPSR_WITH_YAML=false -DKPSR_WITH_SOCKET=true -DCMAKE_BUILD_TYPE=${BUILD_MODE} -DKPSR_WITH_ROS_HUMBLE_OR_ABOVE=true \ |
| 42 | +-DKPSR_TEST_PERFORMANCE=false ../ |
| 43 | +make -j |
| 44 | +sudo make install |
| 45 | +EOF |
| 46 | + |
| 47 | + |
| 48 | +FROM kpe-core as kpe-admin |
| 49 | +ENV KPE_ADMIN_TAG=v6.0.1 |
| 50 | +RUN --mount=type=ssh git clone --branch ${KPE_ADMIN_TAG} --recurse-submodules git@github.com:klepsydra-technologies/kpe-admin |
| 51 | +RUN --mount=type=cache,target=/home/kpsruser/.ccache <<EOF |
| 52 | +cd /home/kpsruser/kpe-admin |
| 53 | +mkdir build && cd build && |
| 54 | +cmake -DKPSR_WITH_SOCKET=true -DKPSR_NO_LICENSE=true -DCMAKE_BUILD_TYPE=${BUILD_MODE} ../ && |
| 55 | +make -j$(nproc) && |
| 56 | +sudo make install |
| 57 | +EOF |
| 58 | + |
| 59 | + |
| 60 | +FROM kpe-admin as kpe-streaming |
| 61 | +ENV KPE_STREAMING_VER=v9.1.1 |
| 62 | +RUN --mount=type=ssh git clone --branch ${KPE_STREAMING_VER} --recurse-submodules git@github.com:klepsydra-technologies/kpe-streaming |
| 63 | +RUN --mount=type=cache,target=/home/kpsruser/.ccache <<EOF |
| 64 | +cd /home/kpsruser/kpe-streaming |
| 65 | +mkdir build && cd build && |
| 66 | +cmake -DCMAKE_BUILD_TYPE=${BUILD_MODE} ../ && |
| 67 | +make -j$(nproc) && |
| 68 | +sudo make install |
| 69 | +EOF |
| 70 | + |
| 71 | +# Install colcon, rosdep and dependencies |
| 72 | +FROM kpe-streaming as kpe-ros2-core |
| 73 | +RUN --mount=type=ssh git clone --recurse-submodules git@github.com:klepsydra-technologies/kpe-ros2-core.git |
| 74 | +ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt |
| 75 | + |
| 76 | +RUN --mount=type=cache,target=/home/kpsruser/.ccache <<EOF |
| 77 | +pip install -U rosdep |
| 78 | +rosdep init && rosdep update --include-eol-distros |
| 79 | + |
| 80 | +. /opt/ros/galactic/local_setup.sh |
| 81 | +mkdir -p /home/kpsruser/kpe-ros2-core-install/src |
| 82 | +ln -s /home/kpsruser/kpe-ros2-core/ /home/kpsruser/kpe-ros2-core-install/src/kpe-ros2-core |
| 83 | +cd /home/kpsruser/kpe-ros2-core-install/ |
| 84 | +rosdep install --from-paths src --ignore-src -r -y && |
| 85 | +colcon build --cmake-args -DCMAKE_BUILD_TYPE=${BUILD_MODE} |
| 86 | +EOF |
| 87 | + |
| 88 | +FROM kpe-ros2-core as reference_sytem |
| 89 | +ENV KPE_REF_SYSTEM=update_klepsydra_executor |
| 90 | +RUN --mount=type=ssh git clone --branch ${KPE_REF_SYSTEM} --recurse-submodules git@github.com:klepsydra-technologies/reference-system.git |
| 91 | + |
| 92 | +RUN --mount=type=cache,target=/home/kpsruser/.ccache <<EOF |
| 93 | +mkdir -p /home/kpsruser/colcon_reference-system/src |
| 94 | + |
| 95 | +ln -s /home/kpsruser/reference-system /home/kpsruser/colcon_reference-system/src/reference-system |
| 96 | +cd /home/kpsruser/colcon_reference-system/ |
| 97 | + |
| 98 | +. /opt/ros/galactic/local_setup.sh |
| 99 | +colcon build --cmake-args -DCMAKE_PREFIX_PATH="/home/kpsruser/kpe-ros2-core-install/install" -DCMAKE_BUILD_TYPE=${BUILD_MODE} -DRUN_BENCHMARK=ON |
| 100 | +EOF |
| 101 | + |
| 102 | +# Necessary. |
| 103 | +ENV LD_LIBRARY_PATH=/home/kpsruser/kpe-ros2-core-install/install/kpsr_ros2_executor/lib:/usr/local/lib:/home/kpsruser/colcon_reference-system/install/reference_interfaces/lib:/opt/ros/galactic/lib/x86_64-linux-gnu:/opt/ros/galactic/lib |
| 104 | + |
0 commit comments