diff --git a/Dockerfile b/Dockerfile index a8beeed..688c403 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,17 @@ FROM alpine:3.18.6 AS builder RUN apk update && apk add --virtual .build-deps \ - build-base gcc wget + build-base gcc wget cmake cunit-dev libpcap-dev \ + ncurses-dev openssl-dev jansson-dev numactl-dev \ + libbsd-dev linux-headers +#Install bngblaster from source +COPY install-bngblaster.sh / +RUN chmod +x /install-bngblaster.sh +RUN /install-bngblaster.sh + +# Install mcjoin from source +WORKDIR / RUN wget https://github.com/troglobit/mcjoin/releases/download/v2.12/mcjoin-2.12.tar.gz RUN tar -xzf mcjoin-2.12.tar.gz WORKDIR /mcjoin-2.12 @@ -44,7 +53,16 @@ RUN mkdir -p /usr/local/gobgp RUN tar -C /usr/local/gobgp -xzf gobgp_3.25.0_linux_amd64.tar.gz RUN cp /usr/local/gobgp/gobgp* /usr/bin/ +# mcjoin binary COPY --from=builder /usr/local/bin/mcjoin /usr/local/bin/ +# bngblaster binaries and dependencies +RUN apk add ncurses openssl jansson +RUN mkdir /run/lock +COPY --from=builder /usr/sbin/bngblaster-cli /usr/sbin/ +COPY --from=builder /usr/bin/bgpupdate /usr/bin/ +COPY --from=builder /usr/bin/ldpupdate /usr/bin/ +COPY --from=builder /usr/sbin/bngblaster /usr/sbin/ +COPY --from=builder /usr/sbin/lspgen /usr/sbin/ RUN rm /etc/motd diff --git a/install-bngblaster.sh b/install-bngblaster.sh new file mode 100644 index 0000000..2d9b1c5 --- /dev/null +++ b/install-bngblaster.sh @@ -0,0 +1,28 @@ +#!/bin/sh +LIBDICT_VERSION="1.0.4" +BNGBLASTER_VERSION="0.9.26" +mkdir /bngblaster +cd /bngblaster +wget https://github.com/rtbrick/libdict/archive/refs/tags/$LIBDICT_VERSION.zip +unzip $LIBDICT_VERSION.zip +mkdir libdict-$LIBDICT_VERSION/build +cd /bngblaster/libdict-$LIBDICT_VERSION/build +cmake .. +make -j16 install +cd /bngblaster +wget https://github.com/rtbrick/bngblaster/archive/refs/tags/$BNGBLASTER_VERSION.zip +unzip $BNGBLASTER_VERSION.zip +mkdir bngblaster-$BNGBLASTER_VERSION/build +cd /bngblaster/bngblaster-$BNGBLASTER_VERSION/build +#remove redundant include to avoid preprocessor redirect warning and consequent compilation failure +sed -i '/#include /d' ../code/lwip/contrib/ports/unix/port/netif/sio.c +#typedef for uint to avoid compilation error on alpine musl libc +sed -i '$i typedef unsigned int uint;' ../code/common/src/common.h +# add include to support be32toh and htobe32 on alpine musl libc +sed -i '/#include /i #include ' ../code/common/src/common.h +#replace __time_t with time_t to make it compatible with alpine musl libc +find /bngblaster/bngblaster-0.9.26/code/ -type f \( -name "*.c" -o -name "*.h" \) -exec sed -i 's/\b__time_t\b/time_t/g' {} + +#Don't error on sequence-point errors to allow build to complete on musl libc. Ideally code should be fixed on upstream repo. +sed -i 's/APPEND CMAKE_C_FLAGS "-pthread"/APPEND CMAKE_C_FLAGS "-pthread -Wno-error=sequence-point"/' ../code/bngblaster/CMakeLists.txt +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBNGBLASTER_VERSION=$BNGBLASTER_VERSION .. +make install \ No newline at end of file