From c20f0bb32976aa1f9d2cc3f6d133d6136fd2586b Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 26 Jan 2020 15:27:08 +0300 Subject: dump1090: multi-stage build I think (?) it let's me _not_ care about removing build artifacts, which is convinient. --- dump1090/Dockerfile | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/dump1090/Dockerfile b/dump1090/Dockerfile index 0edd388..971e912 100644 --- a/dump1090/Dockerfile +++ b/dump1090/Dockerfile @@ -1,36 +1,43 @@ -FROM debian:stretch-slim - -LABEL maintainer="Egor Tensin " +FROM debian:stretch-slim AS builder -WORKDIR /tmp +# Don't prompt: +ENV DEBIAN_FRONTEND=noninteractive # Variables: ARG DUMP1090_VERSION=3.7.2 -# Don't prompt: -ENV DEBIAN_FRONTEND=noninteractive +WORKDIR /tmp -# Build and install the dump1090-fa package: +# Build the dump1090-fa package: ADD ["https://github.com/flightaware/dump1090/archive/v${DUMP1090_VERSION}.tar.gz", "./dump1090-${DUMP1090_VERSION}.tar.gz"] - # dump1090 dependencies (from README at https://github.com/flightaware/dump1090): + # dump1090 build dependencies (from README at https://github.com/flightaware/dump1090/blob/v3.7.2/README.md): RUN build_deps='build-essential debhelper librtlsdr-dev pkg-config dh-systemd libncurses5-dev libbladerf-dev' && \ - # dump1090-fa runtime dependencies: - runtime_deps='librtlsdr0 libncurses5 libbladerf1' && \ - # Supervisor to run both dump1090-fa and lighttpd: - supervisor='supervisor' && \ apt-get update -yq && \ - apt-get install -yq --no-install-recommends $build_deps $runtime_deps $supervisor && \ + apt-get install -yq --no-install-recommends $build_deps && \ tar xzf dump1090-${DUMP1090_VERSION}.tar.gz && \ cd -- dump1090-${DUMP1090_VERSION} && \ dpkg-buildpackage -b && \ - dpkg-buildpackage -Tclean && \ cd -- .. && \ dump1090_arch="$( dpkg --print-architecture )" && \ - apt-get install -yq ./dump1090-fa_${DUMP1090_VERSION}_${dump1090_arch}.deb && \ - rm -rf -- dump1090-${DUMP1090_VERSION}.tar.gz dump1090-${DUMP1090_VERSION}/ && \ - find . -mindepth 1 -maxdepth 1 -type f -\( -name '*.buildinfo' -o -name '*.changes' -o -name '*.deb' -\) -delete && \ - apt-get purge -yq --auto-remove -o APT::AutoRemove::RecommendsImportant=false $build_deps + mv -- dump1090-fa_${DUMP1090_VERSION}_${dump1090_arch}.deb dump1090-fa.deb + +FROM debian:stretch-slim + +LABEL maintainer="Egor Tensin " + +# Don't prompt: +ENV DEBIAN_FRONTEND=noninteractive + +WORKDIR /tmp + +COPY --from=builder ["/tmp/dump1090-fa.deb", "./"] + +RUN apt-get update -yq && \ + # Supervisor to run both dump1090-fa and lighttpd: + apt-get install -yq --no-install-recommends supervisor && \ + apt-get install -yq ./dump1090-fa.deb && \ + rm -- ./dump1090-fa.deb # Create the /run/dump1090-fa directory, typically created by systemd: RUN mkdir --mode=0755 /run/dump1090-fa -- cgit v1.2.3