|
| 1 | +ARG image_base=osrf/ros:humble-desktop |
| 2 | + |
| 3 | +ARG registry=registry.klepsydra.io/repository |
| 4 | +ARG board=amd64 |
| 5 | +ARG osrelease=jammy |
| 6 | + |
| 7 | +FROM $image_base as system_dep |
| 8 | + |
| 9 | +ENV TZ 'Europe/Madrid' |
| 10 | +ENV LC_ALL en_US.UTF-8 |
| 11 | +ENV LANG en_US.UTF-8 |
| 12 | +ENV LANGUAGE en_US.UTF-8 |
| 13 | +ENV DEBIAN_FRONTEND=noninteractive |
| 14 | +RUN groupadd --gid 10000 kpsruser && \ |
| 15 | + useradd --uid 10000 --gid kpsruser --shell /bin/bash --create-home kpsruser && \ |
| 16 | + usermod -aG sudo kpsruser && \ |
| 17 | + echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers |
| 18 | + |
| 19 | +ENV BUILD_MODE=Release |
| 20 | + |
| 21 | +ARG OPENSSLVERSION="OpenSSL_1_1_1i" |
| 22 | +RUN git clone https://github.com/openssl/openssl.git && \ |
| 23 | + cd openssl && git checkout ${OPENSSLVERSION} && \ |
| 24 | + ./config -fPIC shared && \ |
| 25 | + make -j$(nproc) && \ |
| 26 | + make install && \ |
| 27 | + cd ../ && rm -rf openssl |
| 28 | + |
| 29 | +ARG YAMLCPPVERSION="yaml-cpp-0.7.0" |
| 30 | +RUN git clone https://github.com/jbeder/yaml-cpp && \ |
| 31 | + cd yaml-cpp && git checkout ${YAMLCPPVERSION} && \ |
| 32 | + mkdir build && \ |
| 33 | + cd build && \ |
| 34 | + cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DYAML_CPP_BUILD_TESTS=Off ../ && \ |
| 35 | + make -j$(nproc) && \ |
| 36 | + make install && \ |
| 37 | + cd ../../ && rm -rf yaml-cpp |
| 38 | + |
| 39 | +ARG ZMQVERSION="v4.3.4" |
| 40 | +RUN git clone https://github.com/zeromq/libzmq.git && \ |
| 41 | + cd libzmq && \ |
| 42 | + git checkout ${ZMQVERSION} && \ |
| 43 | + mkdir build && \ |
| 44 | + cd build && \ |
| 45 | + cmake ../ && \ |
| 46 | + make -j$(nproc) && \ |
| 47 | + make install && \ |
| 48 | + cd ../../ && rm -rf libzmq |
| 49 | + |
| 50 | +ARG ZMQCPPVERSION="v4.8.0" |
| 51 | +RUN git clone https://github.com/zeromq/cppzmq.git && \ |
| 52 | + cd cppzmq && \ |
| 53 | + git checkout ${ZMQCPPVERSION} && \ |
| 54 | + mkdir build && cd build && \ |
| 55 | + cmake ../ && \ |
| 56 | + make -j$(nproc) && \ |
| 57 | + make install && \ |
| 58 | + cd ../../ && rm -rf cppzmq |
| 59 | + |
| 60 | +ARG BENCHMARKVERSION="3b3de69400164013199ea448f051d94d7fc7d81f" |
| 61 | +RUN git clone https://github.com/google/benchmark.git && \ |
| 62 | + cd benchmark && \ |
| 63 | + git checkout ${BENCHMARKVERSION} && \ |
| 64 | + mkdir build && cd build && \ |
| 65 | + cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release ../ && \ |
| 66 | + make -j$(nproc) && \ |
| 67 | + make install && \ |
| 68 | + cd ../../ && \ |
| 69 | + rm -rf benchmark |
| 70 | + |
| 71 | +RUN apt-get -y update && apt-get -y install libtool |
| 72 | + |
| 73 | +ARG PROTOBUFVERSION="v3.19.0" |
| 74 | +RUN git clone https://github.com/protocolbuffers/protobuf.git && \ |
| 75 | + cd protobuf && \ |
| 76 | + git checkout ${PROTOBUFVERSION} && \ |
| 77 | + git submodule update --init --recursive && \ |
| 78 | + ./autogen.sh && ./configure && \ |
| 79 | + make -j$(nproc) && \ |
| 80 | + sudo make install && ldconfig && \ |
| 81 | + cd ../../ && \ |
| 82 | + rm -rf protobuf |
| 83 | + |
| 84 | +ARG EIGENVERSION="3.4.0" |
| 85 | +RUN git clone https://gitlab.com/libeigen/eigen.git && \ |
| 86 | + cd eigen && \ |
| 87 | + git checkout ${EIGENVERSION} && \ |
| 88 | + mkdir build && cd build && \ |
| 89 | + cmake -DCMAKE_BUILD_TYPE=Release ../ && \ |
| 90 | + make -j$(nproc) && \ |
| 91 | + sudo make install && \ |
| 92 | + cd ../../ && \ |
| 93 | + rm -rf eigen |
| 94 | + |
| 95 | +ARG OPENCVVERSION="3.4.17" |
| 96 | +RUN git clone https://github.com/opencv/opencv.git && \ |
| 97 | + cd opencv && \ |
| 98 | + git checkout ${OPENCVVERSION} && \ |
| 99 | + mkdir build && cd build && \ |
| 100 | + cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DINSTALL_TESTS=OFF -DINSTALL_PYTHON_EXAMPLES=OFF -DINSTALL_C_EXAMPLES=OFF -DBUILD_opencv_apps=OFF ../ && \ |
| 101 | + make -j$(nproc) && \ |
| 102 | + sudo make install && \ |
| 103 | + cd ../../ && \ |
| 104 | + rm -rf opencv |
| 105 | + |
| 106 | + |
| 107 | +USER root |
| 108 | +WORKDIR /home/kpsruser |
| 109 | +RUN <<EOF |
| 110 | +# echo "deb https://${registry}/${board}/ ${osrelease} main" >> /etc/apt/sources.list.d/klepsydra.list |
| 111 | +# apt-key add /tmp/public.gpg.key |
| 112 | +# rm /tmp/public.gpg.key |
| 113 | +# apt update |
| 114 | +apt-get -y install python3-pip |
| 115 | +pip config set global.extra-index-url https://registry.klepsydra.io/repository/kpe-pypi/simple |
| 116 | +pip install kpsr-codegen |
| 117 | +EOF |
| 118 | + |
| 119 | +RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts |
| 120 | + |
| 121 | +FROM system_dep as kpe-core |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | +ENV KPE_CORE_TAG=v8.0.0 |
| 126 | +RUN --mount=type=ssh git clone --branch ${KPE_CORE_TAG} --recurse-submodules git@github.com:klepsydra-technologies/kpe-core |
| 127 | +RUN --mount=type=cache,target=/home/kpsruser/.ccache <<EOF |
| 128 | +cd /home/kpsruser/kpe-core |
| 129 | +# Patch to make it work. |
| 130 | +sed -i 's/set(_SPDLOG_VERSION "1.5")/set(_SPDLOG_VERSION "1.9.2")/g' CMakeLists.txt |
| 131 | +mkdir build |
| 132 | +cd build |
| 133 | +cmake -DKPSR_WITH_YAML=false -DKPSR_WITH_SOCKET=true -DCMAKE_BUILD_TYPE=${BUILD_MODE} -DKPSR_WITH_ROS_HUMBLE_OR_ABOVE=true \ |
| 134 | +-DKPSR_TEST_PERFORMANCE=false ../ |
| 135 | +make -j |
| 136 | +sudo make install |
| 137 | +EOF |
| 138 | + |
| 139 | +FROM kpe-core as kpe-admin |
| 140 | +ENV KPE_ADMIN_TAG=v7.0.0 |
| 141 | +RUN --mount=type=ssh git clone --branch ${KPE_ADMIN_TAG} --recurse-submodules git@github.com:klepsydra-technologies/kpe-admin |
| 142 | +RUN --mount=type=cache,target=/home/kpsruser/.ccache <<EOF |
| 143 | +#apt-get -y install libbsd-dev |
| 144 | +cd /home/kpsruser/kpe-admin |
| 145 | +sed -i '26d' modules/system/src/cpu_reader_linux.cpp |
| 146 | +apt-get -y install glibc |
| 147 | +mkdir build && cd build && |
| 148 | +cmake -DKPSR_WITH_SOCKET=true -DKPSR_NO_LICENSE=true -DCMAKE_BUILD_TYPE=${BUILD_MODE} ../ && |
| 149 | +make -j$(nproc) && |
| 150 | +sudo make install |
| 151 | +EOF |
| 152 | + |
| 153 | + |
| 154 | +FROM kpe-admin as kpe-streaming |
| 155 | +ENV KPE_STREAMING_VER=v11.1.0 |
| 156 | +RUN --mount=type=ssh git clone --branch ${KPE_STREAMING_VER} --recurse-submodules git@github.com:klepsydra-technologies/kpe-streaming |
| 157 | +RUN --mount=type=cache,target=/home/kpsruser/.ccache <<EOF |
| 158 | +cd /home/kpsruser/kpe-streaming |
| 159 | +mkdir build && cd build && |
| 160 | +cmake -DCMAKE_BUILD_TYPE=${BUILD_MODE} ../ && |
| 161 | +make -j$(nproc) && |
| 162 | +sudo make install |
| 163 | +EOF |
| 164 | + |
| 165 | +# Install colcon, rosdep and dependencies |
| 166 | +FROM kpe-streaming as kpe-ros2-core |
| 167 | +ENV KPE_ROS2_CORE_BRANCH=KPE-537-Fixing-dependencies-for-ros2-humble |
| 168 | +RUN --mount=type=ssh git clone --branch ${KPE_ROS2_CORE_BRANCH} --recurse-submodules git@github.com:klepsydra-technologies/kpe-ros2-core.git |
| 169 | +ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt |
| 170 | + |
| 171 | +RUN --mount=type=cache,target=/home/kpsruser/.ccache <<EOF |
| 172 | +pip install -U rosdep |
| 173 | +rosdep init && rosdep update --include-eol-distros |
| 174 | + |
| 175 | +. /opt/ros/humble/local_setup.sh |
| 176 | +mkdir -p /home/kpsruser/kpe-ros2-core-install/src |
| 177 | +ln -s /home/kpsruser/kpe-ros2-core/ /home/kpsruser/kpe-ros2-core-install/src/kpe-ros2-core |
| 178 | +cd /home/kpsruser/kpe-ros2-core-install/ |
| 179 | +rosdep install --from-paths src --ignore-src -r -y && |
| 180 | +colcon build --cmake-args -DCMAKE_BUILD_TYPE=${BUILD_MODE} |
| 181 | +EOF |
| 182 | + |
| 183 | +FROM kpe-ros2-core as reference_sytem |
| 184 | +ENV KPE_REF_SYSTEM=update_klepsydra_executor |
| 185 | +RUN --mount=type=ssh git clone --branch ${KPE_REF_SYSTEM} --recurse-submodules git@github.com:klepsydra-technologies/reference-system.git |
| 186 | + |
| 187 | +RUN --mount=type=cache,target=/home/kpsruser/.ccache <<EOF |
| 188 | +apt-get -y install ros-humble-ros-testing |
| 189 | +mkdir -p /home/kpsruser/colcon_reference-system/src |
| 190 | + |
| 191 | +ln -s /home/kpsruser/reference-system /home/kpsruser/colcon_reference-system/src/reference-system |
| 192 | +cd /home/kpsruser/colcon_reference-system/ |
| 193 | + |
| 194 | +. /opt/ros/humble/local_setup.sh |
| 195 | +colcon build --cmake-args -DCMAKE_PREFIX_PATH="/home/kpsruser/kpe-ros2-core-install/install" -DCMAKE_BUILD_TYPE=${BUILD_MODE} -DRUN_BENCHMARK=ON |
| 196 | +EOF |
| 197 | + |
| 198 | +RUN apt-get -y install ros-humble-rmw-cyclonedds-cpp |
| 199 | +RUN pip install pandas==2.0.1 bokeh==2.4.1 psrecord==1.2 numpy==1.24.3 |
| 200 | +RUN chmod +x /home/kpsruser/reference-system/autoware_reference_system/scripts/benchmark.py |
| 201 | +# Necessary. |
| 202 | +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/humble/lib/x86_64-linux-gnu:/opt/ros/humble/lib |
| 203 | + |
| 204 | +RUN sed -i 's/parallised/parallelised/g' /home/kpsruser/colcon_reference-system/src/reference-system/autoware_reference_system/src/ros2/data/streaming_policy.json |
| 205 | +# if this doesn't work YOU NEED TO MODIFY THE POLICY. parallised BECOMES parallelised. |
| 206 | + |
| 207 | +USER kpsruser |
| 208 | + |
| 209 | +RUN echo 'source /opt/ros/humble/setup.sh' >> /home/kpsruser/.bashrc && |
| 210 | + echo 'source /home/kpsruser/colcon_reference-system/install/setup.sh' >> /home/kpsruser/.bashrc && |
| 211 | + echo 'source /home/kpsruser/kpe-ros2-core-install/install/setup.sh' >> /home/kpsruser/.bashrc |
0 commit comments