From 170abf2e3da21f5364b7b92117a0df1c3b413463 Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Tue, 26 May 2020 15:45:49 +0200 Subject: [PATCH] Build container: Base build image on Debian Stretch (#24967) * scripts/build/ci-build: Fix Makefile * scripts/build/ci-build: Base Docker image on Debian Stretch * scripts/build/ci-build: Modify Dockerfile for fewer RUN directives --- scripts/build/ci-build/Dockerfile | 20 +++++++++++--------- scripts/build/ci-build/Makefile | 10 +++++----- scripts/build/ci-build/README.md | 7 ++++--- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/scripts/build/ci-build/Dockerfile b/scripts/build/ci-build/Dockerfile index 370a12bc374..aa91036a271 100644 --- a/scripts/build/ci-build/Dockerfile +++ b/scripts/build/ci-build/Dockerfile @@ -1,4 +1,5 @@ -FROM ubuntu:20.04 as toolchain +# Use old Debian (this has support into 2022) in order to ensure binary compatibility with older glibc's. +FROM debian:stretch-20200514 AS toolchain ENV OSX_SDK_URL=https://s3.dockerproject.org/darwin/v2 \ OSX_SDK=MacOSX10.10.sdk \ @@ -71,8 +72,9 @@ RUN cd /tmp && \ rm -rf /tmp/x86_64-centos6-linux-gnu/ && \ rm -rf /tmp/crosstool-ng-${CTNG} -# base image to crossbuild grafana -FROM ubuntu:20.04 +# Base image to crossbuild grafana. +# Use old Debian (this has support into 2022) in order to ensure binary compatibility with older glibc's. +FROM debian:stretch-20200514 ENV GOVERSION=1.14.1 \ PATH=/usr/local/go/bin:$PATH \ @@ -86,7 +88,7 @@ COPY --from=toolchain /tmp/x86_64-centos6-linux-gnu.tar.xz /tmp/osxcross.tar.xz RUN apt-get update && \ apt-get upgrade -yq && \ apt-get install -yq \ - clang gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-mingw-w64-x86-64 \ + build-essential clang gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-mingw-w64-x86-64 \ apt-transport-https \ ca-certificates \ curl \ @@ -99,7 +101,12 @@ RUN apt-get update && \ xz-utils \ expect \ gnupg2 \ + procps \ + ruby \ + ruby-dev \ + rubygems \ unzip && \ + gem install -N fpm && \ ln -s /usr/bin/llvm-dsymutil-6.0 /usr/bin/dsymutil && \ curl -fL https://nodejs.org/dist/v${NODEVERSION}/node-v${NODEVERSION}-linux-x64.tar.xz \ | tar -xJ --strip-components=1 -C /usr/local && \ @@ -130,9 +137,4 @@ RUN cd /tmp && \ tar xf x86_64-linux-musl-cross.tgz && \ rm x86_64-linux-musl-cross.tgz -RUN apt-get install -yq gcc libc-dev make && \ - gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && \ - curl -fsSL https://get.rvm.io | bash -s stable && \ - /bin/bash -l -c "rvm requirements && rvm install 2.2 && gem install -N fpm" - COPY ./bootstrap.sh /tmp/bootstrap.sh diff --git a/scripts/build/ci-build/Makefile b/scripts/build/ci-build/Makefile index 64fa376d7cf..5645595c348 100644 --- a/scripts/build/ci-build/Makefile +++ b/scripts/build/ci-build/Makefile @@ -1,7 +1,7 @@ -VERSION="dev" -TAG="grafana/build-container" -USER_ID=$(shell id -u) -GROUP_ID=$(shell id -g) +VERSION = dev +TAG = grafana/build-container +USER_ID = $(shell id -u) +GROUP_ID = $(shell id -g) all: build deploy @@ -41,7 +41,7 @@ run-with-local-source-copy: docker exec -ti grafana-build bash update-source: - docker cp "${GOPATH}/src/github.com/grafana/grafana" grafana-build:/go/src/github.com/grafana/ + docker cp "${GOPATH}/src/github.com/grafana/grafana" grafana-build:/go/src/github.com/grafana/ attach: docker exec -ti grafana-build bash diff --git a/scripts/build/ci-build/README.md b/scripts/build/ci-build/README.md index 69e7747e91f..d8697a32442 100644 --- a/scripts/build/ci-build/README.md +++ b/scripts/build/ci-build/README.md @@ -1,9 +1,10 @@ # grafana-build-container -Grafana build container -## Description +These are the sources for the Docker image that we use for the Grafana build containers. The image source itself +is in Dockerfile, but there are supporting scripts such as the Makefile, for building images. -This is a container for cross-platform builds of Grafana. You can run it locally using the Makefile. +The image is based on Debian Stretch, since we want an older Linux distribution (Stretch has long-term support into +2022) to build binaries that are as portable as possible. ## Makefile targets