# dev/Dockerfile.arm.musl
ARG CROSS_BASE_IMAGE
FROM ${CROSS_BASE_IMAGE}

# Base tools
RUN apt-get update \
  && apt-get install -y --no-install-recommends \
    build-essential gperf pkg-config \
    wget ca-certificates \
    linux-libc-dev

# Build libseccomp statically
ENV SECCOMP_VER=2.6.0

RUN wget https://github.com/seccomp/libseccomp/releases/download/v${SECCOMP_VER}/libseccomp-${SECCOMP_VER}.tar.gz \
 && tar -xvpf libseccomp-${SECCOMP_VER}.tar.gz \
 && cd libseccomp-${SECCOMP_VER} \
 && ./configure --host=arm-linux-musleabihf --enable-static --disable-shared \
        --prefix=/usr/local/arm-linux-musleabihf \
 && make -j"$(nproc)" >&2 \
 && make install >&2 \
 && cd / && rm -rf libseccomp-${SECCOMP_VER} libseccomp-${SECCOMP_VER}.tar.gz

 RUN ln -s /usr/local/lib/gcc/arm-linux-musleabihf/9.2.0/crtbegin.o /usr/local/arm-linux-musleabihf/lib
 RUN ln -s /usr/local/lib/gcc/arm-linux-musleabihf/9.2.0/crtend.o /usr/local/arm-linux-musleabihf/lib
 RUN ln -sf /usr/local/lib/gcc/arm-linux-musleabihf/9.2.0/libgcc_eh.a /usr/local/arm-linux-musleabihf/lib/libunwind.a
