Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 8 additions & 2 deletions .github/workflows/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
# Run once for each of the platforms
strategy:
matrix:
platform: ["generic", "orinnx"]
platform: ["generic_k1", "orinnx"]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down Expand Up @@ -65,6 +65,10 @@ jobs:
- name: Enforce file permissions
run: chmod -Rv g-w,o-w docker/

- name: Get CPU count
id: cpu-count
run: echo "count=$(nproc)" >> $GITHUB_OUTPUT

# Build the docker image
- name: 🐳 Build and push the docker image 🐳
uses: docker/build-push-action@v4
Expand All @@ -73,7 +77,9 @@ jobs:
tags: "nubots/nubots:${{ matrix.platform }}"
file: docker/Dockerfile
context: docker
build-args: platform=${{ matrix.platform }}
build-args: |
platform=${{ matrix.platform == 'generic_k1' && 'generic' || matrix.platform }}
jobs=${{ steps.cpu-count.outputs.count }}
cache-from: type=registry,ref=nubots/nubots:${{ matrix.platform }}
cache-to: type=inline
push: true
8 changes: 7 additions & 1 deletion .github/workflows/nubots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ jobs:
- name: Enforce file permissions
run: chmod -Rv g-w,o-w docker/

- name: Get CPU count
id: cpu-count
run: echo "count=$(nproc)" >> $GITHUB_OUTPUT

# Build and push the docker image
- name: 🐳 Build the docker image 🐳
uses: docker/build-push-action@v4
Expand All @@ -129,7 +133,9 @@ jobs:
type=registry,ref=nubots/nubots:${{ env.DOCKER_TAG }}
type=registry,ref=nubots/nubots:generic
cache-to: type=inline
build-args: platform=generic
build-args: |
platform=generic
jobs=${{ steps.cpu-count.outputs.count }}
push: true

- id: image_output
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/nusight.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ jobs:
- name: Enforce file permissions
run: chmod -Rv g-w,o-w docker/

- name: Get CPU count
id: cpu-count
run: echo "count=$(nproc)" >> $GITHUB_OUTPUT

# Build and push the docker image
- name: 🐳 Build the docker image 🐳
uses: docker/build-push-action@v4
Expand All @@ -133,7 +137,9 @@ jobs:
type=registry,ref=nubots/nubots:${{ env.DOCKER_TAG }}
type=registry,ref=nubots/nubots:generic
cache-to: type=inline
build-args: platform=generic
build-args: |
platform=generic
jobs=${{ steps.cpu-count.outputs.count }}
push: true

- id: image_output
Expand Down
109 changes: 78 additions & 31 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ RUN --mount=type=bind,source=usr/local/toolchain,target=/usr/local/toolchain \
# |_|\___/ \___/|_|\___|_| |_|\__,_|_|_| |_| #
################################################
ARG prefix=/usr/local
ARG jobs=1

# Install prefix/toolchain-dir for source-built dependencies below, computed once per platform
RUN if [ "${platform}" = "orinnx" ]; then \
echo "DEP_PREFIX=/l4t/targetfs${prefix}" > /root/.dep_env && \
echo "DEP_TOOLCHAIN='--toolchain-dir /usr/local'" >> /root/.dep_env; \
else \
echo "DEP_PREFIX=/usr/local" > /root/.dep_env && \
echo "DEP_TOOLCHAIN=''" >> /root/.dep_env; \
fi

# Create a python virtual environment at ${PREFIX} to decouple python packages from the system
RUN python3 -m venv ${prefix}
Expand All @@ -133,16 +143,20 @@ RUN install-package -p ${platform} libncurses-dev libncurses6 libtinfo6 libc6-de
RUN pip3 install pyyaml mako

# Install OpenCL C Headers
RUN install-from-source https://github.com/KhronosGroup/OpenCL-Headers/archive/refs/tags/v2022.05.18.tar.gz \
--prefix /l4t/targetfs/${prefix} \
--toolchain-dir /usr/local
RUN . /root/.dep_env && \
install-from-source https://github.com/KhronosGroup/OpenCL-Headers/archive/refs/tags/v2022.05.18.tar.gz \
--jobs ${jobs} \
--prefix ${DEP_PREFIX} \
${DEP_TOOLCHAIN}


# OpenCL loader library
RUN install-package ruby autotools-dev automake libtool
RUN install-from-source https://github.com/OCL-dev/ocl-icd/archive/refs/tags/v2.3.1.tar.gz \
--prefix /l4t/targetfs/${prefix} \
--toolchain-dir /usr/local
RUN . /root/.dep_env && \
install-from-source https://github.com/OCL-dev/ocl-icd/archive/refs/tags/v2.3.1.tar.gz \
--jobs ${jobs} \
--prefix ${DEP_PREFIX} \
${DEP_TOOLCHAIN}

RUN if [ "${platform}" != "generic" ]; then \
ln -sf libm.so.6 /l4t/targetfs/usr/lib/aarch64-linux-gnu/libm.so && \
Expand All @@ -152,14 +166,16 @@ RUN if [ "${platform}" != "generic" ]; then \
fi

# OpenCV
RUN install-from-source https://github.com/opencv/opencv/archive/refs/tags/4.9.0.tar.gz
RUN install-from-source https://github.com/opencv/opencv/archive/refs/tags/4.9.0.tar.gz \
--jobs ${jobs}

RUN wget -nv https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-linux-x86_64.zip -O protoc-21.4-linux-x86_64.zip && \
unzip protoc-21.4-linux-x86_64.zip -d /usr/ && \
rm protoc-21.4-linux-x86_64.zip

# Protobuf
RUN install-from-source https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protobuf-cpp-3.21.4.tar.gz \
--jobs ${jobs} \
-Dprotobuf_PROTOC_EXECUTABLE="/usr/bin/protoc" \
-Dprotobuf_BUILD_TESTS=OFF \
-Dprotobuf_BUILD_LIBPROTOC=ON \
Expand All @@ -171,6 +187,7 @@ RUN if [ "${platform}" != "generic" ]; then \
unzip protoc-21.4-linux-aarch_64.zip -d /l4t/targetfs/usr/ && \
rm protoc-21.4-linux-aarch_64.zip && \
install-from-source https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protobuf-cpp-3.21.4.tar.gz \
--jobs ${jobs} \
--toolchain-dir /usr \
-Dprotobuf_PROTOC_EXECUTABLE="/usr/bin/protoc" \
-Dprotobuf_BUILD_TESTS=OFF \
Expand All @@ -192,6 +209,7 @@ RUN install-package opencl-c-headers \


RUN install-from-source https://github.com/uxlfoundation/oneTBB/archive/refs/tags/v2021.13.0.tar.gz \
--jobs ${jobs} \
--build-system cmake \
-DCMAKE_BUILD_TYPE=Release \
-DTBB_TEST:BOOL='OFF' \
Expand Down Expand Up @@ -219,13 +237,14 @@ RUN mkdir build && cd build && \
-DENABLE_SYSTEM_PROTOBUF:BOOL='OFF' \
-DENABLE_SYSTEM_FLATBUFFERS:BOOL='OFF' \
-DENABLE_INTEL_GPU:BOOL='OFF' \
-DENABLE_INTEL_CPU:BOOL='OFF' \
-DENABLE_ARM_COMPUTE_CMAKE:BOOL='ON' \
-DENABLE_INTEL_CPU:BOOL='ON' \
-DENABLE_ARM_COMPUTE_CMAKE:BOOL='OFF' \
-DARM_COMPUTE_SCONS_JOBS="${jobs}" \
-DENABLE_CPPLINT:BOOL='OFF' \
-DCMAKE_CXX_STANDARD='17' \
-Wno-dev \
-GNinja && \
ninja -j$(nproc) && ninja -j$(nproc) install
ninja -j${jobs} && ninja -j${jobs} install

# Move OpenVino libraries to our library path
RUN ARCH=$([ "${platform}" = "orinnx" ] && echo "aarch64" || echo "intel64") && \
Expand Down Expand Up @@ -260,19 +279,23 @@ RUN install-package -p ${platform} \
libnvinfer-vc-plugin-dev

# Eigen3
RUN install-from-source https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz
RUN install-from-source https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz \
--jobs ${jobs}

# tcmalloc
RUN install-from-source https://github.com/gperftools/gperftools/releases/download/gperftools-2.10/gperftools-2.10.tar.gz \
RUN . /root/.dep_env && \
install-from-source https://github.com/gperftools/gperftools/releases/download/gperftools-2.10/gperftools-2.10.tar.gz \
--jobs ${jobs} \
--build-system autotools \
--prefix /l4t/targetfs/${prefix} \
--toolchain-dir /usr/local \
--prefix ${DEP_PREFIX} \
${DEP_TOOLCHAIN} \
--with-tcmalloc-pagesize=64 \
--enable-minimal

# Libjpeg
RUN install-package yasm
RUN install-from-source https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/2.0.7-esr.tar.gz \
--jobs ${jobs} \
-DWITH_SIMD=ON \
-DFORCE_INLINE=ON \
-DINLINE_WORKS=1 \
Expand All @@ -286,16 +309,19 @@ RUN install-from-source https://github.com/libjpeg-turbo/libjpeg-turbo/archive/r

# yaml-cpp
RUN install-from-source https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.7.0.tar.gz \
--jobs ${jobs} \
-DYAML_CPP_BUILD_TESTS=OFF \
-DBUILD_SHARED_LIBS=OFF

# fmt formatting library
RUN install-from-source https://github.com/fmtlib/fmt/archive/refs/tags/9.0.0.tar.gz \
--jobs ${jobs} \
-DFMT_DOC=OFF \
-DFMT_TEST=OFF

# Catch unit testing library
RUN install-from-source https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.0.tar.gz \
--jobs ${jobs} \
-DCATCH_CONFIG_CONSOLE_WIDTH=120 \
-DCATCH_CONFIG_CPP11_TO_STRING=ON \
-DCATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS=ON \
Expand All @@ -306,69 +332,83 @@ RUN install-from-source https://github.com/catchorg/Catch2/archive/refs/tags/v3.

# LibUV
RUN install-from-source https://github.com/libuv/libuv/archive/refs/tags/v1.44.2.tar.gz \
--jobs ${jobs} \
-Dlibuv_buildtests=OFF \
-DBUILD_TESTING=OFF

# NUClear!
RUN install-from-source https://github.com/Fastcode/NUClear/archive/925dca0f31484a7df64fd335de5a6c9335483c7f.tar.gz \
--jobs ${jobs} \
-DBUILD_TESTS=OFF

# Backtrace
RUN install-from-source https://github.com/ianlancetaylor/libbacktrace/archive/8602fda64e78f1f46563220f2ee9f7e70819c51d.tar.gz \
--prefix /l4t/targetfs/${prefix} \
--toolchain-dir /usr/local \
RUN . /root/.dep_env && \
install-from-source https://github.com/ianlancetaylor/libbacktrace/archive/8602fda64e78f1f46563220f2ee9f7e70819c51d.tar.gz \
--jobs ${jobs} \
--prefix ${DEP_PREFIX} \
${DEP_TOOLCHAIN} \
--without-system-libunwind \
--enable-shared \
--enable-static

# Alsa and espeak
RUN install-from-source https://github.com/alsa-project/alsa-lib/archive/refs/tags/v1.2.7.2.tar.gz \
--prefix /l4t/targetfs/${prefix} \
--toolchain-dir /usr/local \
RUN . /root/.dep_env && \
install-from-source https://github.com/alsa-project/alsa-lib/archive/refs/tags/v1.2.7.2.tar.gz \
--jobs ${jobs} \
--prefix ${DEP_PREFIX} \
${DEP_TOOLCHAIN} \
--without-debug
RUN install-package -p ${platform} alsa-utils

# mio memory mapping library
RUN install-from-source https://github.com/mandreyel/mio/archive/3f86a95c0784d73ce6815237ec33ed25f233b643.tar.gz \
--jobs ${jobs} \
--patch https://patch-diff.githubusercontent.com/raw/mandreyel/mio/pull/93.patch

# zstr header to have file streams that do zlib compression
RUN INCLUDE_PREFIX=$([ "${platform}" = "orinnx" ] && echo "/l4t/targetfs/usr/local" || echo "/usr/local") && \
RUN . /root/.dep_env && \
install-from-source https://raw.githubusercontent.com/mateidavid/zstr/v1.0.6/src/zstr.hpp \
--prefix ${INCLUDE_PREFIX} --no-toolchain \
--prefix ${DEP_PREFIX} --no-toolchain \
--header-path include/zstr && \
install-from-source https://raw.githubusercontent.com/mateidavid/zstr/v1.0.6/src/strict_fstream.hpp \
--prefix ${INCLUDE_PREFIX} --no-toolchain \
--prefix ${DEP_PREFIX} --no-toolchain \
--header-path include/zstr

# Visual Mesh
RUN install-from-source https://github.com/NUbots/VisualMesh/archive/64c49fce3a17bbee73339eaee556f47a80b93c40.tar.gz \
--jobs ${jobs} \
-DBUILD_TENSORFLOW_OP=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_OPENCL_ENGINE=ON

# JSON for modern C++ (https://github.com/nlohmann/json)
RUN INCLUDE_PREFIX=$([ "${platform}" = "orinnx" ] && echo "/l4t/targetfs/usr/local" || echo "/usr/local") && \
RUN . /root/.dep_env && \
install-from-source https://github.com/nlohmann/json/releases/download/v3.10.5/json.hpp \
--prefix ${INCLUDE_PREFIX} --no-toolchain
--prefix ${DEP_PREFIX} --no-toolchain

# TinyXML
RUN install-from-source https://github.com/leethomason/tinyxml2/archive/refs/tags/9.0.0.tar.gz
RUN install-from-source https://github.com/leethomason/tinyxml2/archive/refs/tags/9.0.0.tar.gz \
--jobs ${jobs}

# NLopt
RUN install-from-source https://github.com/stevengj/nlopt/archive/refs/tags/v2.7.1.tar.gz
RUN install-from-source https://github.com/stevengj/nlopt/archive/refs/tags/v2.7.1.tar.gz \
--jobs ${jobs}

# tinyrobotics
RUN install-from-source https://github.com/Tom0Brien/tinyrobotics/archive/refs/tags/0.0.1.tar.gz \
--jobs ${jobs} \
-DBUILD_TESTS=OFF

# lame
RUN install-from-source https://downloads.sourceforge.net/lame/lame-3.100.tar.gz \
--prefix /l4t/targetfs/${prefix} \
--toolchain-dir /usr/local
RUN . /root/.dep_env && \
install-from-source https://downloads.sourceforge.net/lame/lame-3.100.tar.gz \
--jobs ${jobs} \
--prefix ${DEP_PREFIX} \
${DEP_TOOLCHAIN}

# Nanopb for generating messages for NUSense
RUN install-from-source https://github.com/nanopb/nanopb/archive/refs/tags/0.4.9.1.tar.gz
RUN install-from-source https://github.com/nanopb/nanopb/archive/refs/tags/0.4.9.1.tar.gz \
--jobs ${jobs}

# Install Booster Robotics SDK

Expand Down Expand Up @@ -401,6 +441,9 @@ RUN install-package \
gcc-12 \
g++-12

# qemu lets ctest run the cross compiled test binaries, see CMAKE_CROSSCOMPILING_EMULATOR in the toolchain
RUN if [ "${platform}" != "generic" ]; then install-package qemu-user-static; fi


# Node tools
RUN wget -nv https://nodejs.org/dist/v20.13.1/node-v20.13.1-linux-x64.tar.xz -O - \
Expand All @@ -427,6 +470,10 @@ RUN install-package clinfo
# Copy the nvidia OpenCL vendorfile into the container so we can also use OpenCL on nvidia GPUs
COPY --chown=root:root etc/OpenCL/vendors/nvidia.icd /etc/OpenCL/vendors/nvidia.icd

# Creates symlink for librt since CUDAToolkit CMake module can't find it
# See: https://notes.rdu.im/howtos/fix-librt-not-found-in-jammy/
RUN ln -s /lib/x86_64-linux-gnu/librt.so.1 /usr/lib/x86_64-linux-gnu/librt.so

# Re-run ldconfig to make sure the database is up to date
RUN ldconfig

Expand Down
Loading