From c5fe5f801a8c61ddf0261e5afbd5b8ec5a18e1b8 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 24 Mar 2020 11:28:43 +0100 Subject: [PATCH 1/2] deb: use non-interactive, and no-install-recommends The devscripts package on newer Ubuntu/Debian versions adds a HUGE amount of new dependencies. Unfortunately we need this package as it's the only package that provides `mk-build-deps`, but we don't have to install all recommended packages: On Ubuntu 20.04, without `--no-install-recommends`: 4 upgraded, 334 newly installed, 0 to remove and 4 not upgraded. Need to get 100 MB of archives. After this operation, 445 MB of additional disk space will be used. And with `--no-install-recommends`; 0 upgraded, 104 newly installed, 0 to remove and 8 not upgraded. Need to get 25.0 MB of archives. After this operation, 119 MB of additional disk space will be used. This patch also sets `DEBIAN_FRONTEND=noninteractive`, to prevent build hanging if a package (such as `tzdata`) waits for user input otherwise. Signed-off-by: Sebastiaan van Stijn --- dockerfiles/deb.dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dockerfiles/deb.dockerfile b/dockerfiles/deb.dockerfile index 59cb2dd8..5bbfbf5c 100644 --- a/dockerfiles/deb.dockerfile +++ b/dockerfiles/deb.dockerfile @@ -39,9 +39,10 @@ RUN go get github.com/cpuguy83/go-md2man/v2/@${MD2MAN_VERSION} FROM ${BUILD_IMAGE} RUN cat /etc/os-release +ARG DEBIAN_FRONTEND=noninteractive # Install some pre-reqs -RUN apt-get update && apt-get install -y curl devscripts equivs git lsb-release +RUN apt-get update && apt-get install -y --no-install-recommends curl devscripts equivs git lsb-release RUN mkdir -p /go ENV GOPATH=/go From acac3811cf8fdcb691566f6b5a92e5d3de99eb4e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 24 Mar 2020 11:48:56 +0100 Subject: [PATCH 2/2] deb: clean-up caches, and refresh when needed This patch removes the apt-cache after installing packages, and refreshes (`apt-get update`) before installing dependencies using `mk-build-deps` to prevent using a possibly stale index when dependencies in the control file change. Signed-off-by: Sebastiaan van Stijn --- dockerfiles/deb.dockerfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dockerfiles/deb.dockerfile b/dockerfiles/deb.dockerfile index 5bbfbf5c..7db83657 100644 --- a/dockerfiles/deb.dockerfile +++ b/dockerfiles/deb.dockerfile @@ -42,7 +42,14 @@ RUN cat /etc/os-release ARG DEBIAN_FRONTEND=noninteractive # Install some pre-reqs -RUN apt-get update && apt-get install -y --no-install-recommends curl devscripts equivs git lsb-release +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl \ + devscripts \ + equivs \ + git \ + lsb-release \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* RUN mkdir -p /go ENV GOPATH=/go @@ -56,7 +63,10 @@ COPY debian/ /root/containerd/debian/ WORKDIR /root/containerd # Install all of our build dependencies, if any -RUN mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i debian/control +RUN apt-get update \ + && mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i debian/control \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* # Copy over our entrypoint COPY scripts/build-deb /build-deb