FROM ubuntu:22.04 # Set up architectures first RUN dpkg --add-architecture arm64 && \ sed -i 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list && \ echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe multiverse" >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe multiverse" >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse" >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse" >> /etc/apt/sources.list # Install build dependencies for both architectures RUN apt-get update && \ apt-get install -y \ cmake \ make \ g++ \ wget \ git \ g++-aarch64-linux-gnu \ crossbuild-essential-arm64 \ libtbb-dev \ libtbb2 \ libtbb-dev:arm64 \ libtbb2:arm64 \ libxxhash-dev \ libxxhash0 \ libxxhash-dev:arm64 \ libxxhash0:arm64 && \ rm -rf /var/lib/apt/lists/* # Build musl cross compilers with C++ support RUN git clone https://github.com/richfelker/musl-cross-make.git && \ cd musl-cross-make && \ echo "TARGET = x86_64-linux-musl" > config.mak && \ echo "OUTPUT = /opt/cross" >> config.mak && \ echo "COMMON_CONFIG += CFLAGS=\"-g0 -O2\" CXXFLAGS=\"-g0 -O2\" LDFLAGS=\"-s\"" >> config.mak && \ echo "GCC_CONFIG += --enable-languages=c,c++" >> config.mak && \ make -j$(nproc) && \ make install && \ cd .. && \ rm -rf musl-cross-make # Build arm64 musl cross compiler RUN git clone https://github.com/richfelker/musl-cross-make.git && \ cd musl-cross-make && \ echo "TARGET = aarch64-linux-musl" > config.mak && \ echo "OUTPUT = /opt/cross" >> config.mak && \ echo "COMMON_CONFIG += CFLAGS=\"-g0 -O2\" CXXFLAGS=\"-g0 -O2\" LDFLAGS=\"-s\"" >> config.mak && \ echo "GCC_CONFIG += --enable-languages=c,c++" >> config.mak && \ make -j$(nproc) && \ make install && \ cd .. && \ rm -rf musl-cross-make # Add cross compilers to PATH ENV PATH="/opt/cross/bin:${PATH}" # Install TBB from source for musl compatibility RUN wget https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.10.0.tar.gz && \ tar xf v2021.10.0.tar.gz && \ cd oneTBB-2021.10.0 && \ mkdir build && \ cd build && \ cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF .. && \ make -j$(nproc) && \ make install && \ cd ../.. && \ rm -rf oneTBB-2021.10.0 v2021.10.0.tar.gz # Install xxHash from source for musl compatibility RUN wget https://github.com/Cyan4973/xxHash/archive/refs/tags/v0.8.2.tar.gz && \ tar xf v0.8.2.tar.gz && \ cd xxHash-0.8.2 && \ make -j$(nproc) && \ make install && \ cd .. && \ rm -rf xxHash-0.8.2 v0.8.2.tar.gz WORKDIR /src