From 6820b6668a148516a0fe064ba56431a8d184162b Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 11 Aug 2020 21:54:13 +0200 Subject: [PATCH] Refactor dockerfile to reduce build time --- Dockerfile | 108 ++++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 56 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4ec97c9..019df47 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,44 @@ +FROM debian:buster AS builder + +# Build-time dependencies +RUN apt-get update && apt-get install -y \ + build-essential \ + pkg-config \ + qt5-default \ + libqt5svg5* \ + libboost-dev \ + libasound2-dev \ + libssl-dev \ + libspeechd-dev \ + libzeroc-ice-dev \ + libpulse-dev \ + libcap-dev \ + libprotobuf-dev \ + libprotoc-dev \ + protobuf-compiler \ + protobuf-compiler-grpc \ + libgrpc++-dev \ + libogg-dev \ + libavahi-compat-libdnssd-dev \ + libsndfile1-dev \ + libbz2-dev \ + libxi-dev \ + git --no-install-recommends + +WORKDIR /usr/src/murmur +RUN \ + git clone https://github.com/mumble-voip/mumble.git \ + && git checkout master \ + && git submodule init \ + && git submodule update + +RUN \ + qmake -recursive main.pro CONFIG+="no-client no-g15 no-bonjour grpc" \ + && make release \ + && cp -r release/ /home/user/release \ + && chmod a+r release -R + + FROM debian:buster EXPOSE 64738/tcp 64738/udp @@ -5,71 +46,26 @@ ENV HOME /home/user RUN useradd --create-home --home-dir $HOME user \ && chown -R user:user $HOME -# Runtime dependencies for murmurd +WORKDIR $HOME + +# Runtime dependencies RUN apt-get update && apt-get install -y \ - ca-certificates \ - libprotobuf17 \ + ca-certificates \ + 'libprotobuf[0-9]+$' \ + libqt5core5a \ + libqt5dbus5 \ libqt5xml5 \ libqt5sql5 \ libqt5network5 \ libcap2 \ - libgrpc6 \ + 'libgrpc[0-9]+$' \ libgrpc++1 \ libzeroc-ice3.7 \ - && rm -rf /var/lib/apt/lists/* + && apt-get clean && rm -rf /var/lib/apt/lists/* -# The build dependencies will be uninstalled after compilation, -# so the image doesn't get bloated. -RUN buildDeps=' \ - build-essential \ - pkg-config \ - qt5-default \ - qtbase5-dev \ - qttools5-dev \ - qttools5-dev-tools \ - libqt5svg5* \ - libspeex1 \ - libspeex-dev \ - libboost-dev \ - libasound2-dev \ - libssl-dev \ - g++ \ - libspeechd-dev \ - libzeroc-ice-dev \ - zeroc-ice-slice \ - libpulse-dev \ - libcap-dev \ - libspeexdsp-dev \ - libprotobuf-dev \ - libprotoc-dev \ - protobuf-compiler \ - protobuf-compiler-grpc \ - libgrpc-dev \ - libgrpc++-dev \ - libogg-dev \ - libavahi-compat-libdnssd-dev \ - libsndfile1-dev \ - libxi-dev \ - git \ - ' \ - && set -x \ - && apt-get update && apt-get install -y $buildDeps --no-install-recommends \ - && rm -rf /var/lib/apt/lists/* \ - && mkdir -p /usr/src/murmur \ - && git clone https://github.com/mumble-voip/mumble.git /usr/src/murmur \ - && cd /usr/src/murmur \ - && git checkout 7c67ea33f47716a188da045ead2035f978fc6253 \ - && git submodule init \ - && git submodule update \ - && qmake -recursive main.pro CONFIG+="no-client no-g15 no-bonjour grpc" \ - && make \ - && cp -r release/ /home/user/release \ - && chmod a+r /home/user/release -R \ - && rm -rf /usr/src/murmur \ - && apt-get purge -y --auto-remove $buildDeps +COPY --from=builder /usr/src/murmur/release/murmurd /usr/bin/murmurd -WORKDIR $HOME USER user -ENTRYPOINT [ "/home/user/release/murmurd" ] +ENTRYPOINT [ "/usr/bin/murmurd" ] CMD [ "-fg", "-v", "-ini", "/data/murmur.ini" ]