From 94027c0f5891b32d80fbd7b15dfc8bcaae0b3f27 Mon Sep 17 00:00:00 2001 From: zhangn1985 <832666+zhangn1985@users.noreply.github.com> Date: Tue, 9 Jul 2019 18:04:24 +0800 Subject: [PATCH] Docker build speed up. (#1451) * Docker: a chance to rebuild docker image when Dockerfile is updated, docker image will not be rebuilt, let armbian docker image tag with framework version, thus has a chance to rebuild it. V2: use VERSION file to track build script version. Signed-off-by: Zhang Ning <832666+zhangn1985@users.noreply.github.com> * Docker: use upgrade instead of dist-upgrade to speed up docker build this patch also change to use apt instead of apt-get when compile in docker, it will run apt update&&upgrade everytime. this is very time consuming. apt-get dist-upgrade will not upgrade packages, thus will make build framework do upgrade each time. Signed-off-by: Zhang Ning <832666+zhangn1985@users.noreply.github.com> --- Dockerfile | 2 +- VERSION | 1 + config-docker.conf | 9 +++++---- lib/configuration.sh | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 VERSION diff --git a/Dockerfile b/Dockerfile index 7d8a30570..7e87edf24 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:18.04 RUN dpkg --add-architecture i386 -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade && \ +RUN apt update && DEBIAN_FRONTEND=noninteractive apt -y upgrade && \ DEBIAN_FRONTEND=noninteractive apt-get install -y git dialog lsb-release binutils wget ca-certificates device-tree-compiler \ pv bc lzop zip binfmt-support build-essential ccache debootstrap ntpdate gawk gcc-arm-linux-gnueabihf \ qemu-user-static u-boot-tools uuid-dev zlib1g-dev unzip libusb-1.0-0-dev parted pkg-config libncurses5-dev whiptail \ diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..103c55458 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +5.91 diff --git a/config-docker.conf b/config-docker.conf index aab4f7103..2f134df22 100644 --- a/config-docker.conf +++ b/config-docker.conf @@ -13,13 +13,14 @@ shift mkdir -p $SRC/{output,userpatches} grep -q '^docker:' /etc/group && chgrp --quiet docker $SRC/{output,userpatches} chmod --quiet g+w,g+s $SRC/{output,userpatches} - -if grep -q armbian <(docker images); then +VERSION=$(cat VERSION) +if grep -q $VERSION <(grep armbian <(docker images)); then display_alert "Using existed a armbian Docker container" else # build a new container based on provided Dockerfile + display_alert "Docker container not found or out of date" display_alert "Building a Docker container" - if ! docker build -t armbian . ; then + if ! docker build -t armbian:$VERSION . ; then STATUS=$? # Adding a newline, so the alert won't be shown in the same line as the error echo @@ -82,7 +83,7 @@ DOCKER_FLAGS+=(-e COLUMNS="`tput cols`" -e LINES="`tput lines`") # pass other command line arguments like KERNEL_ONLY=yes, KERNEL_CONFIGURE=yes, etc. # pass "docker-guest" as an additional config name that will be sourced in the container if exists display_alert "Running the container" "" "info" -docker run "${DOCKER_FLAGS[@]}" -it armbian docker-guest "$@" +docker run "${DOCKER_FLAGS[@]}" -it armbian:$VERSION docker-guest "$@" # Docker error treatment STATUS=$? diff --git a/lib/configuration.sh b/lib/configuration.sh index 9583c98d9..a5801c843 100644 --- a/lib/configuration.sh +++ b/lib/configuration.sh @@ -12,7 +12,7 @@ # common options # daily beta build contains date in subrevision if [[ $BETA == yes && -z $SUBREVISION ]]; then SUBREVISION="."$(date --date="tomorrow" +"%y%m%d"); fi -REVISION="5.91$SUBREVISION" # all boards have same revision +REVISION=$(cat VERSION)"$SUBREVISION" # all boards have same revision ROOTPWD="1234" # Must be changed @first login [[ -z $MAINTAINER ]] && MAINTAINER="Igor Pecovnik" # deb signature [[ -z $MAINTAINERMAIL ]] && MAINTAINERMAIL="igor.pecovnik@****l.com" # deb signature