From 8d10fc573f76df937f7c4d4cdbfd242eb5439334 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Tue, 22 Jan 2019 14:52:53 +0000 Subject: [PATCH] move stuff to alpine to reduce image size (sdrplay not woking yet) --- build.sh | 6 +-- docker/Dockerfiles/Dockerfile-base | 2 + docker/Dockerfiles/Dockerfile-rtlsdr | 3 +- docker/Dockerfiles/Dockerfile-sdrplay | 3 +- docker/scripts/install-dependencies-rtlsdr.sh | 25 +++++++-- .../scripts/install-dependencies-sdrplay.sh | 12 ++--- docker/scripts/install-dependencies.sh | 51 ++++++++++++++++--- 7 files changed, 79 insertions(+), 23 deletions(-) diff --git a/build.sh b/build.sh index 7d85499..79fdda1 100755 --- a/build.sh +++ b/build.sh @@ -8,14 +8,14 @@ case $ARCH in BASE_IMAGE=debian:stretch ;; armv*) - BASE_IMAGE=raspbian/stretch + BASE_IMAGE=arm32v6/alpine esac TAGS=$ARCH docker build --build-arg BASE_IMAGE=$BASE_IMAGE -t openwebrx-base:$ARCH -f docker/Dockerfiles/Dockerfile-base . -docker build -t jketterl/openwebrx-rtlsdr:$ARCH -t jketterl/openwebrx:$ARCH -f docker/Dockerfiles/Dockerfile-rtlsdr . -docker build -t jketterl/openwebrx-sdrplay:$ARCH -f docker/Dockerfiles/Dockerfile-sdrplay . +docker build --build-arg ARCH=$ARCH -t jketterl/openwebrx-rtlsdr:$ARCH -t jketterl/openwebrx:$ARCH -f docker/Dockerfiles/Dockerfile-rtlsdr . +docker build --build-arg ARCH=$ARCH -t jketterl/openwebrx-sdrplay:$ARCH -f docker/Dockerfiles/Dockerfile-sdrplay . if [ "$ARCH" == "armv7l" ]; then for image in openwebrx openwebrx-rtlsdr openwebrx-sdrplay; do diff --git a/docker/Dockerfiles/Dockerfile-base b/docker/Dockerfiles/Dockerfile-base index 3f30eb5..f58d41e 100644 --- a/docker/Dockerfiles/Dockerfile-base +++ b/docker/Dockerfiles/Dockerfile-base @@ -1,6 +1,8 @@ ARG BASE_IMAGE FROM $BASE_IMAGE +RUN apk add --no-cache bash + ADD docker/scripts/install-dependencies.sh / RUN /install-dependencies.sh diff --git a/docker/Dockerfiles/Dockerfile-rtlsdr b/docker/Dockerfiles/Dockerfile-rtlsdr index 5daba32..3e14ab0 100644 --- a/docker/Dockerfiles/Dockerfile-rtlsdr +++ b/docker/Dockerfiles/Dockerfile-rtlsdr @@ -1,4 +1,5 @@ -FROM openwebrx-base +ARG ARCH +FROM openwebrx-base:$ARCH ADD docker/scripts/install-dependencies-rtlsdr.sh / RUN /install-dependencies-rtlsdr.sh diff --git a/docker/Dockerfiles/Dockerfile-sdrplay b/docker/Dockerfiles/Dockerfile-sdrplay index c38f9d1..1e11c8a 100644 --- a/docker/Dockerfiles/Dockerfile-sdrplay +++ b/docker/Dockerfiles/Dockerfile-sdrplay @@ -1,4 +1,5 @@ -FROM openwebrx-base +ARG ARCH +FROM openwebrx-base:$ARCH ADD docker/scripts/install-dependencies-sdrplay.sh / RUN /install-dependencies-sdrplay.sh diff --git a/docker/scripts/install-dependencies-rtlsdr.sh b/docker/scripts/install-dependencies-rtlsdr.sh index 1417bac..09f8676 100755 --- a/docker/scripts/install-dependencies-rtlsdr.sh +++ b/docker/scripts/install-dependencies-rtlsdr.sh @@ -1,9 +1,26 @@ #!/bin/bash set -euxo pipefail -apt-get update -apt-get -y install --no-install-recommends rtl-sdr +function cmakebuild() { + cd $1 + mkdir build + cd build + cmake .. + make + make install + cd ../.. + rm -rf $1 +} -apt-get autoremove --purge -y -rm -rf /var/lib/apt/lists/* +cd /tmp +STATIC_PACKAGES="libusb" +BUILD_PACKAGES="git libusb-dev cmake make gcc musl-dev g++ linux-headers" + +apk add --no-cache $STATIC_PACKAGES +apk add --no-cache --virtual .build-deps $BUILD_PACKAGES + +git clone https://github.com/osmocom/rtl-sdr.git +cmakebuild rtl-sdr + +apk del .build-deps diff --git a/docker/scripts/install-dependencies-sdrplay.sh b/docker/scripts/install-dependencies-sdrplay.sh index 4961057..c6c003c 100755 --- a/docker/scripts/install-dependencies-sdrplay.sh +++ b/docker/scripts/install-dependencies-sdrplay.sh @@ -14,11 +14,11 @@ function cmakebuild() { cd /tmp -STATIC_PACKAGES="libusb-1.0.0-dev" -BUILD_PACKAGES="git build-essential cmake patch ca-certificates wget sudo udev" +STATIC_PACKAGES="libusb" +BUILD_PACKAGES="git cmake make patch wget sudo udev gcc g++ libusb-dev" -apt-get update -apt-get -y install --no-install-recommends $STATIC_PACKAGES $BUILD_PACKAGES +apk add --no-cache $STATIC_PACKAGES +apk add --no-cache --virtual .build-deps $BUILD_PACKAGES case $(arch) in x86_64) @@ -69,6 +69,4 @@ cmakebuild SoapySDRPlay git clone https://github.com/rxseger/rx_tools cmakebuild rx_tools -SUDO_FORCE_REMOVE=yes apt-get remove --purge --autoremove -y $BUILD_PACKAGES -rm -rf /var/lib/apt/lists/* - +apk del .build-deps diff --git a/docker/scripts/install-dependencies.sh b/docker/scripts/install-dependencies.sh index ac0149d..b3049d3 100755 --- a/docker/scripts/install-dependencies.sh +++ b/docker/scripts/install-dependencies.sh @@ -14,14 +14,53 @@ function cmakebuild() { cd /tmp -STATIC_PACKAGES="sox libfftw3-dev python2.7 netcat libitpp-dev libsndfile1-dev" -BUILD_PACKAGES="git build-essential cmake ca-certificates" +STATIC_PACKAGES="sox fftw python2 netcat-openbsd libsndfile lapack" +BUILD_PACKAGES="git libsndfile-dev fftw-dev cmake ca-certificates make gcc musl-dev g++ lapack-dev linux-headers" -apt-get update -apt-get -y install --no-install-recommends $STATIC_PACKAGES $BUILD_PACKAGES +apk add --no-cache $STATIC_PACKAGES +apk add --no-cache --virtual .build-deps $BUILD_PACKAGES + +git clone https://git.code.sf.net/p/itpp/git itpp +cmakebuild itpp git clone https://github.com/simonyiszk/csdr.git cd csdr +patch -Np1 <<'EOF' +--- a/csdr.c ++++ b/csdr.c +@@ -38,6 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #include + #include + #include ++#include + #include + #include + #include +diff --git a/ddcd_old.h b/ddcd_old.h +index af4cfb5..b70092b 100644 +--- a/ddcd_old.h ++++ b/ddcd_old.h +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + + typedef struct client_s + { +diff --git a/nmux.h b/nmux.h +index 038bc51..079e416 100644 +--- a/nmux.h ++++ b/nmux.h +@@ -11,6 +11,7 @@ + #include + #include + #include ++#include + #include "tsmpool.h" + + #define MSG_START "nmux: " +EOF make make install cd .. @@ -36,6 +75,4 @@ cmakebuild digiham git clone https://github.com/f4exb/dsd.git cmakebuild dsd -apt-get remove --purge --autoremove -y $BUILD_PACKAGES -rm -rf /var/lib/apt/lists/* - +apk del .build-deps