From f47ebb2adb21042313dcf12533dbb0419364c733 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Tue, 1 Sep 2020 23:30:48 +0200 Subject: [PATCH] docker optimization * move openwebrx project tools to a separate layer for lower download volume and faster builds * use COPY instead of ADD * COPY multiple files at once to reduce number of layers --- docker/Dockerfiles/Dockerfile-airspy | 2 +- docker/Dockerfiles/Dockerfile-base | 9 ++-- docker/Dockerfiles/Dockerfile-fcdpp | 4 +- docker/Dockerfiles/Dockerfile-full | 13 +++--- docker/Dockerfiles/Dockerfile-hackrf | 4 +- docker/Dockerfiles/Dockerfile-limesdr | 4 +- docker/Dockerfiles/Dockerfile-perseus | 4 +- docker/Dockerfiles/Dockerfile-plutosdr | 4 +- docker/Dockerfiles/Dockerfile-radioberry | 4 +- docker/Dockerfiles/Dockerfile-rtlsdr | 6 +-- docker/Dockerfiles/Dockerfile-rtlsdr-soapy | 4 +- docker/Dockerfiles/Dockerfile-sdrplay | 8 ++-- docker/Dockerfiles/Dockerfile-soapyremote | 4 +- docker/Dockerfiles/Dockerfile-soapysdr | 4 +- docker/scripts/install-dependencies.sh | 23 +--------- docker/scripts/install-owrx-tools.sh | 49 ++++++++++++++++++++++ 16 files changed, 88 insertions(+), 58 deletions(-) create mode 100755 docker/scripts/install-owrx-tools.sh diff --git a/docker/Dockerfiles/Dockerfile-airspy b/docker/Dockerfiles/Dockerfile-airspy index d332bb5..94b348b 100644 --- a/docker/Dockerfiles/Dockerfile-airspy +++ b/docker/Dockerfiles/Dockerfile-airspy @@ -1,7 +1,7 @@ ARG ARCHTAG FROM openwebrx-soapysdr-base:$ARCHTAG -ADD docker/scripts/install-dependencies-airspy.sh / +COPY docker/scripts/install-dependencies-airspy.sh / RUN /install-dependencies-airspy.sh &&\ rm /install-dependencies-airspy.sh diff --git a/docker/Dockerfiles/Dockerfile-base b/docker/Dockerfiles/Dockerfile-base index c044fd7..a62f998 100644 --- a/docker/Dockerfiles/Dockerfile-base +++ b/docker/Dockerfiles/Dockerfile-base @@ -1,11 +1,14 @@ FROM debian:buster-slim -ADD docker/files/js8call/js8call-hamlib.patch / -ADD docker/files/wsjtx/*.patch / -ADD docker/scripts/install-dependencies.sh / +COPY docker/files/js8call/js8call-hamlib.patch \ + docker/files/wsjtx/*.patch \ + docker/scripts/install-dependencies.sh \ + docker/scripts/install-owrx-tools.sh / RUN /install-dependencies.sh && \ rm /install-dependencies.sh && \ rm /*.patch +RUN /install-owrx-tools.sh && \ + rm /install-owrx-tools.sh ENTRYPOINT ["/init"] diff --git a/docker/Dockerfiles/Dockerfile-fcdpp b/docker/Dockerfiles/Dockerfile-fcdpp index d9ad1fc..3e28ac7 100644 --- a/docker/Dockerfiles/Dockerfile-fcdpp +++ b/docker/Dockerfiles/Dockerfile-fcdpp @@ -1,8 +1,8 @@ ARG ARCHTAG FROM openwebrx-soapysdr-base:$ARCHTAG -ADD docker/scripts/install-dependencies-fcdpp.sh / +COPY docker/scripts/install-dependencies-fcdpp.sh / RUN /install-dependencies-fcdpp.sh &&\ rm /install-dependencies-fcdpp.sh -ADD . /opt/openwebrx +COPY . /opt/openwebrx diff --git a/docker/Dockerfiles/Dockerfile-full b/docker/Dockerfiles/Dockerfile-full index 6a8a1e6..7965e1f 100644 --- a/docker/Dockerfiles/Dockerfile-full +++ b/docker/Dockerfiles/Dockerfile-full @@ -1,8 +1,9 @@ ARG ARCHTAG FROM openwebrx-base:$ARCHTAG -ADD docker/scripts/install-dependencies-*.sh / -ADD docker/files/sdrplay/install-lib.*.patch / +COPY docker/scripts/install-dependencies-*.sh \ + docker/files/sdrplay/install-lib.*.patch \ + docker/scripts/install-connectors.sh / RUN /install-dependencies-rtlsdr.sh &&\ /install-dependencies-soapysdr.sh &&\ @@ -16,13 +17,11 @@ RUN /install-dependencies-rtlsdr.sh &&\ /install-dependencies-perseus.sh &&\ /install-dependencies-fcdpp.sh &&\ /install-dependencies-radioberry.sh &&\ + /install-connectors.sh &&\ rm /install-dependencies-*.sh &&\ - rm /install-lib.*.patch - -ADD docker/scripts/install-connectors.sh / -RUN /install-connectors.sh &&\ + rm /install-lib.*.patch && \ rm /install-connectors.sh -ADD docker/files/services/sdrplay /etc/services.d/sdrplay +COPY docker/files/services/sdrplay /etc/services.d/sdrplay ADD . /opt/openwebrx diff --git a/docker/Dockerfiles/Dockerfile-hackrf b/docker/Dockerfiles/Dockerfile-hackrf index 93cb35b..6dab0f1 100644 --- a/docker/Dockerfiles/Dockerfile-hackrf +++ b/docker/Dockerfiles/Dockerfile-hackrf @@ -1,8 +1,8 @@ ARG ARCHTAG FROM openwebrx-soapysdr-base:$ARCHTAG -ADD docker/scripts/install-dependencies-hackrf.sh / +COPY docker/scripts/install-dependencies-hackrf.sh / RUN /install-dependencies-hackrf.sh &&\ rm /install-dependencies-hackrf.sh -ADD . /opt/openwebrx +COPY . /opt/openwebrx diff --git a/docker/Dockerfiles/Dockerfile-limesdr b/docker/Dockerfiles/Dockerfile-limesdr index 54b7a37..9603c60 100644 --- a/docker/Dockerfiles/Dockerfile-limesdr +++ b/docker/Dockerfiles/Dockerfile-limesdr @@ -1,8 +1,8 @@ ARG ARCHTAG FROM openwebrx-soapysdr-base:$ARCHTAG -ADD docker/scripts/install-dependencies-limesdr.sh / +COPY docker/scripts/install-dependencies-limesdr.sh / RUN /install-dependencies-limesdr.sh &&\ rm /install-dependencies-limesdr.sh -ADD . /opt/openwebrx +COPY . /opt/openwebrx diff --git a/docker/Dockerfiles/Dockerfile-perseus b/docker/Dockerfiles/Dockerfile-perseus index 8a3faaa..bc16583 100644 --- a/docker/Dockerfiles/Dockerfile-perseus +++ b/docker/Dockerfiles/Dockerfile-perseus @@ -1,8 +1,8 @@ ARG ARCHTAG FROM openwebrx-base:$ARCHTAG -ADD docker/scripts/install-dependencies-perseus.sh / +COPY docker/scripts/install-dependencies-perseus.sh / RUN /install-dependencies-perseus.sh &&\ rm /install-dependencies-perseus.sh -ADD . /opt/openwebrx +COPY . /opt/openwebrx diff --git a/docker/Dockerfiles/Dockerfile-plutosdr b/docker/Dockerfiles/Dockerfile-plutosdr index d91e3f1..4a263e8 100644 --- a/docker/Dockerfiles/Dockerfile-plutosdr +++ b/docker/Dockerfiles/Dockerfile-plutosdr @@ -1,8 +1,8 @@ ARG ARCHTAG FROM openwebrx-soapysdr-base:$ARCHTAG -ADD docker/scripts/install-dependencies-plutosdr.sh / +COPY docker/scripts/install-dependencies-plutosdr.sh / RUN /install-dependencies-plutosdr.sh &&\ rm /install-dependencies-plutosdr.sh -ADD . /opt/openwebrx +COPY . /opt/openwebrx diff --git a/docker/Dockerfiles/Dockerfile-radioberry b/docker/Dockerfiles/Dockerfile-radioberry index 9eabed8..3cbe978 100644 --- a/docker/Dockerfiles/Dockerfile-radioberry +++ b/docker/Dockerfiles/Dockerfile-radioberry @@ -1,8 +1,8 @@ ARG ARCHTAG FROM openwebrx-soapysdr-base:$ARCHTAG -ADD docker/scripts/install-dependencies-radioberry.sh / +COPY docker/scripts/install-dependencies-radioberry.sh / RUN /install-dependencies-radioberry.sh &&\ rm /install-dependencies-radioberry.sh -ADD . /opt/openwebrx +COPY . /opt/openwebrx diff --git a/docker/Dockerfiles/Dockerfile-rtlsdr b/docker/Dockerfiles/Dockerfile-rtlsdr index 5e24074..6144641 100644 --- a/docker/Dockerfiles/Dockerfile-rtlsdr +++ b/docker/Dockerfiles/Dockerfile-rtlsdr @@ -1,12 +1,12 @@ ARG ARCHTAG FROM openwebrx-base:$ARCHTAG -ADD docker/scripts/install-dependencies-rtlsdr.sh / -ADD docker/scripts/install-connectors.sh / +COPY docker/scripts/install-dependencies-rtlsdr.sh \ + docker/scripts/install-connectors.sh / RUN /install-dependencies-rtlsdr.sh &&\ rm /install-dependencies-rtlsdr.sh &&\ /install-connectors.sh &&\ rm /install-connectors.sh -ADD . /opt/openwebrx +COPY . /opt/openwebrx diff --git a/docker/Dockerfiles/Dockerfile-rtlsdr-soapy b/docker/Dockerfiles/Dockerfile-rtlsdr-soapy index 47de00d..5dce90f 100644 --- a/docker/Dockerfiles/Dockerfile-rtlsdr-soapy +++ b/docker/Dockerfiles/Dockerfile-rtlsdr-soapy @@ -1,8 +1,8 @@ ARG ARCHTAG FROM openwebrx-soapysdr-base:$ARCHTAG -ADD docker/scripts/install-dependencies-rtlsdr-soapy.sh / +COPY docker/scripts/install-dependencies-rtlsdr-soapy.sh / RUN /install-dependencies-rtlsdr-soapy.sh &&\ rm /install-dependencies-rtlsdr-soapy.sh -ADD . /opt/openwebrx +COPY . /opt/openwebrx diff --git a/docker/Dockerfiles/Dockerfile-sdrplay b/docker/Dockerfiles/Dockerfile-sdrplay index ec649f2..bb53d7e 100644 --- a/docker/Dockerfiles/Dockerfile-sdrplay +++ b/docker/Dockerfiles/Dockerfile-sdrplay @@ -1,12 +1,12 @@ ARG ARCHTAG FROM openwebrx-soapysdr-base:$ARCHTAG -ADD docker/scripts/install-dependencies-sdrplay.sh / -ADD docker/files/sdrplay/install-lib.*.patch / +COPY docker/scripts/install-dependencies-sdrplay.sh \ + docker/files/sdrplay/install-lib.*.patch / RUN /install-dependencies-sdrplay.sh &&\ rm /install-dependencies-sdrplay.sh &&\ rm /install-lib.*.patch -ADD docker/files/services/sdrplay /etc/services.d/sdrplay +COPY docker/files/services/sdrplay /etc/services.d/sdrplay -ADD . /opt/openwebrx +COPY . /opt/openwebrx diff --git a/docker/Dockerfiles/Dockerfile-soapyremote b/docker/Dockerfiles/Dockerfile-soapyremote index 312af40..e5c207c 100644 --- a/docker/Dockerfiles/Dockerfile-soapyremote +++ b/docker/Dockerfiles/Dockerfile-soapyremote @@ -1,8 +1,8 @@ ARG ARCHTAG FROM openwebrx-soapysdr-base:$ARCHTAG -ADD docker/scripts/install-dependencies-soapyremote.sh / +COPY docker/scripts/install-dependencies-soapyremote.sh / RUN /install-dependencies-soapyremote.sh &&\ rm /install-dependencies-soapyremote.sh -ADD . /opt/openwebrx +COPY . /opt/openwebrx diff --git a/docker/Dockerfiles/Dockerfile-soapysdr b/docker/Dockerfiles/Dockerfile-soapysdr index c3f8626..45ac693 100644 --- a/docker/Dockerfiles/Dockerfile-soapysdr +++ b/docker/Dockerfiles/Dockerfile-soapysdr @@ -1,8 +1,8 @@ ARG ARCHTAG FROM openwebrx-base:$ARCHTAG -ADD docker/scripts/install-dependencies-soapysdr.sh / -ADD docker/scripts/install-connectors.sh / +COPY docker/scripts/install-dependencies-soapysdr.sh \ + docker/scripts/install-connectors.sh / RUN /install-dependencies-soapysdr.sh &&\ rm /install-dependencies-soapysdr.sh &&\ /install-connectors.sh &&\ diff --git a/docker/scripts/install-dependencies.sh b/docker/scripts/install-dependencies.sh index 0043b67..86d88c8 100755 --- a/docker/scripts/install-dependencies.sh +++ b/docker/scripts/install-dependencies.sh @@ -19,7 +19,7 @@ function cmakebuild() { cd /tmp STATIC_PACKAGES="sox libfftw3-bin python3 python3-setuptools netcat-openbsd libsndfile1 liblapack3 libusb-1.0-0 libqt5core5a libreadline7 libgfortran4 libgomp1 libasound2 libudev1 ca-certificates libqt5gui5 libqt5sql5 libqt5printsupport5" -BUILD_PACKAGES="wget git libsndfile1-dev libfftw3-dev cmake make gcc g++ liblapack-dev autoconf automake libtool texinfo gfortran libusb-1.0-0-dev qtbase5-dev qtmultimedia5-dev qttools5-dev libqt5serialport5-dev qttools5-dev-tools asciidoctor asciidoc libasound2-dev pkg-config libudev-dev libhamlib-dev patch xsltproc" +BUILD_PACKAGES="wget git libsndfile1-dev libfftw3-dev cmake make gcc g++ liblapack-dev texinfo gfortran libusb-1.0-0-dev qtbase5-dev qtmultimedia5-dev qttools5-dev libqt5serialport5-dev qttools5-dev-tools asciidoctor asciidoc libasound2-dev libudev-dev libhamlib-dev patch xsltproc" apt-get update apt-get -y install auto-apt-proxy apt-get -y install --no-install-recommends $STATIC_PACKAGES $BUILD_PACKAGES @@ -42,33 +42,12 @@ tar xzf s6-overlay-${PLATFORM}.tar.gz -C / rm s6-overlay-${PLATFORM}.tar.gz popd -git clone https://github.com/jketterl/js8py.git -pushd js8py -git checkout 888e62be375316882ad2b2ac8e396c3bf857b6fc -python3 setup.py install -popd -rm -rf js8py - git clone https://git.code.sf.net/p/itpp/git itpp cmakebuild itpp bb5c7e95f40e8fdb5c3f3d01a84bcbaf76f3676d -git clone https://github.com/jketterl/csdr.git -cd csdr -# develop as of 2020-08-28 -git checkout 6d60d8c71f3484fd502174a2af27ceaaec6e60f8 -autoreconf -i -./configure -make -make install -cd .. -rm -rf csdr - git clone https://github.com/szechyjs/mbelib.git cmakebuild mbelib 9a04ed5c78176a9965f3d43f7aa1b1f5330e771f -git clone https://github.com/jketterl/digiham.git -cmakebuild digiham 95206501be89b38d0267bf6c29a6898e7c65656f - git clone https://github.com/f4exb/dsd.git cmakebuild dsd f6939f9edbbc6f66261833616391a4e59cb2b3d7 diff --git a/docker/scripts/install-owrx-tools.sh b/docker/scripts/install-owrx-tools.sh new file mode 100755 index 0000000..aac232f --- /dev/null +++ b/docker/scripts/install-owrx-tools.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -euxo pipefail +export MAKEFLAGS="-j4" + +function cmakebuild() { + cd $1 + if [[ ! -z "${2:-}" ]]; then + git checkout $2 + fi + mkdir build + cd build + cmake ${CMAKE_ARGS:-} .. + make + make install + cd ../.. + rm -rf $1 +} + +cd /tmp + +STATIC_PACKAGES="libfftw3-bin" +BUILD_PACKAGES="git autoconf automake libtool libfftw3-dev pkg-config cmake make gcc g++" +apt-get update +apt-get -y install --no-install-recommends $STATIC_PACKAGES $BUILD_PACKAGES + +git clone https://github.com/jketterl/js8py.git +pushd js8py +git checkout 888e62be375316882ad2b2ac8e396c3bf857b6fc +python3 setup.py install +popd +rm -rf js8py + +git clone https://github.com/jketterl/csdr.git +cd csdr +# develop as of 2020-08-28 +git checkout 6d60d8c71f3484fd502174a2af27ceaaec6e60f8 +autoreconf -i +./configure +make +make install +cd .. +rm -rf csdr + +git clone https://github.com/jketterl/digiham.git +cmakebuild digiham 95206501be89b38d0267bf6c29a6898e7c65656f + +apt-get -y purge --autoremove $BUILD_PACKAGES +apt-get clean +rm -rf /var/lib/apt/lists/*