diff --git a/Jenkinsfile b/Jenkinsfile index 9bdfa096..423f1af4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ @Library('apm@current') _ pipeline { - agent { label 'ubuntu && immutable' } + agent { label 'ubuntu-20 && immutable' } environment { REPO = 'golang-crossbuild' BASE_DIR = "src/github.com/elastic/${env.REPO}" @@ -35,37 +35,54 @@ pipeline { stash name: 'source', useDefaultExcludes: false } } - stage('Build') { - steps { - withGithubNotify(context: 'Build') { - deleteDir() - unstash 'source' - buildImages() - } - } - } - stage('Staging') { - environment { - REPOSITORY = "${env.STAGING_IMAGE}" - } - steps { - withGithubNotify(context: 'Staging') { - // It will use the already cached docker images that were created in the - // Build stage. But it's required to retag them with the staging repo. - buildImages() - publishImages() + stage('Package'){ + matrix { + agent { label 'ubuntu-20 && immutable' } + axes { + axis { + name "MAKEFILE" + values 'Makefile', 'Makefile.debian7', 'Makefile.debian8', 'Makefile.debian9', 'Makefile.debian10' + } + axis { + name 'GO_FOLDER' + values 'go1.10', 'go1.11', 'go1.12', 'go1.13', 'go1.14' + } } - } - } - stage('Release') { - when { - branch 'master' - } - stages { - stage('Publish') { - steps { - withGithubNotify(context: 'Publish') { - publishImages() + stages { + stage('Build') { + steps { + withGithubNotify(context: 'Build') { + deleteDir() + unstash 'source' + buildImages() + } + } + } + stage('Staging') { + environment { + REPOSITORY = "${env.STAGING_IMAGE}" + } + steps { + withGithubNotify(context: 'Staging') { + // It will use the already cached docker images that were created in the + // Build stage. But it's required to retag them with the staging repo. + buildImages() + publishImages() + } + } + } + stage('Release') { + when { + branch 'master' + } + stages { + stage('Publish') { + steps { + withGithubNotify(context: 'Publish') { + publishImages() + } + } + } } } } @@ -82,7 +99,7 @@ pipeline { def buildImages(){ withGoEnv(){ dir("${env.BASE_DIR}"){ - sh 'make build' + sh 'make -c ${GO_FOLDER} -f ${MAKEFILE} build' } } } diff --git a/Makefile b/Makefile index a45ea9da..e64435fa 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,8 @@ build: $(MAKE) -C $(var) $@; \ $(MAKE) -C $(var) -f Makefile.debian7 $@; \ $(MAKE) -C $(var) -f Makefile.debian8 $@; \ - $(MAKE) -C $(var) -f Makefile.debian9 $@;) + $(MAKE) -C $(var) -f Makefile.debian9 $@; \ + $(MAKE) -C $(var) -f Makefile.debian10 $@;) @make -C fpm $@ # Requires login at https://docker.elastic.co:7000/. @@ -14,7 +15,8 @@ push: $(MAKE) -C $(var) $@; \ $(MAKE) -C $(var) -f Makefile.debian7 $@; \ $(MAKE) -C $(var) -f Makefile.debian8 $@; \ - $(MAKE) -C $(var) -f Makefile.debian9 $@;) + $(MAKE) -C $(var) -f Makefile.debian9 $@; \ + $(MAKE) -C $(var) -f Makefile.debian10 $@;) @make -C fpm $@ .PHONY: build push diff --git a/go1.14/Makefile.common b/go1.14/Makefile.common index 7525d209..bee526f7 100644 --- a/go1.14/Makefile.common +++ b/go1.14/Makefile.common @@ -3,7 +3,7 @@ include $(SELF_DIR)/../Makefile.common NAME := golang-crossbuild VERSION := 1.14.7 -DEBIAN_VERSION ?= 9 +DEBIAN_VERSION ?= 7 SUFFIX := -$(shell basename $(CURDIR)) TAG_EXTENSION ?= diff --git a/go1.14/Makefile.debian10 b/go1.14/Makefile.debian10 new file mode 100644 index 00000000..04126feb --- /dev/null +++ b/go1.14/Makefile.debian10 @@ -0,0 +1,14 @@ +IMAGES := base main darwin +DEBIAN_VERSION := 10 +TAG_EXTENSION := -debian10 + +export DEBIAN_VERSION TAG_EXTENSION + +build: + @$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;) + +# Requires login at https://docker.elastic.co:7000/. +push: + @$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;) + +.PHONY: build push diff --git a/go1.14/Makefile.debian8 b/go1.14/Makefile.debian8 index a9de1e2e..11834e52 100644 --- a/go1.14/Makefile.debian8 +++ b/go1.14/Makefile.debian8 @@ -1,10 +1,11 @@ -IMAGES := base main +IMAGES := base main darwin DEBIAN_VERSION := 8 TAG_EXTENSION := -debian8 export DEBIAN_VERSION TAG_EXTENSION build: + export |grep TAG_EXTENSION @$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;) # Requires login at https://docker.elastic.co:7000/. diff --git a/go1.14/Makefile.debian9 b/go1.14/Makefile.debian9 index d7eacbde..26265d60 100644 --- a/go1.14/Makefile.debian9 +++ b/go1.14/Makefile.debian9 @@ -1,4 +1,4 @@ -IMAGES := base main +IMAGES := base main arm darwin mips ppc s390x DEBIAN_VERSION := 9 TAG_EXTENSION := -debian9 diff --git a/go1.14/arm/Dockerfile.tmpl b/go1.14/arm/Dockerfile.tmpl index 9a29dd58..febe3723 100644 --- a/go1.14/arm/Dockerfile.tmpl +++ b/go1.14/arm/Dockerfile.tmpl @@ -1,21 +1,16 @@ ARG REPOSITORY ARG VERSION -FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} RUN \ dpkg --add-architecture arm64 \ -# && dpkg --add-architecture armhf \ -# && dpkg --add-architecture armel \ && apt-get update -qq \ && apt-get install -qq -y \ --no-install-recommends \ --allow-unauthenticated \ crossbuild-essential-arm64 \ - crossbuild-essential-armel \ - crossbuild-essential-armhf \ linux-libc-dev-arm64-cross \ - linux-libc-dev-armel-cross \ - linux-libc-dev-armhf-cross \ librpm-dev:arm64 \ libc-dev:arm64 \ libpopt-dev:arm64 \ @@ -26,30 +21,25 @@ RUN \ libicu57:arm64 \ icu-devtools:arm64 \ libsystemd-dev:arm64 \ -# librpm-dev:armhf \ -# libc-dev:armhf \ -# libpopt-dev:armhf \ -# linux-libc-dev:armhf \ -# libxml2-dev:armhf \ -# libxml2:armhf \ -# libicu-dev:armhf \ -# libicu57:armhf \ -# icu-devtools:armhf \ -# libsystemd-dev:armhf \ -# librpm-dev:armel \ -# libc-dev:armel \ -# libpopt-dev:armel \ -# linux-libc-dev:armel \ -# libxml2-dev:armel \ -# libxml2:armel \ -# libicu-dev:armel \ -# libicu57:armel \ -# icu-devtools:armel \ -# libsystemd-dev:armel \ + librpm3:arm64 \ + librpmio3:arm64 \ + librpmbuild3:arm64 \ + librpmsign3:arm64 \ + libsqlite3-dev:arm64 \ + libnss3:arm64 \ + libsqlite3-0:arm64 \ && rm -rf /var/lib/apt/lists/* COPY rootfs / +# Basic test +RUN cd / \ + && aarch64-linux-gnu-gcc helloWorld.c -o helloWorld \ + && file helloWorld \ + && readelf -h helloWorld \ + && file helloWorld | cut -d "," -f 2 | grep -c 'ARM aarch64'\ + && rm helloWorld.c helloWorld + # Build-time metadata as defined at http://label-schema.org. ARG BUILD_DATE ARG IMAGE diff --git a/go1.14/arm/rootfs/helloWorld.c b/go1.14/arm/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go1.14/arm/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/go1.14/base/Dockerfile.tmpl b/go1.14/base/Dockerfile.tmpl index 6406e571..2d25b754 100644 --- a/go1.14/base/Dockerfile.tmpl +++ b/go1.14/base/Dockerfile.tmpl @@ -1,14 +1,12 @@ ARG DEBIAN_VERSION FROM debian:${DEBIAN_VERSION} -{{if or (eq .DEBIAN_VERSION "7") (eq .DEBIAN_VERSION "8") -}} +ARG TAG_EXTENSION # Replace sources.list in order to use archive.debian.org. -COPY sources-debian{{.DEBIAN_VERSION}}.list /etc/apt/sources.list -{{- end}} +COPY sources${TAG_EXTENSION}.list /etc/apt/sources.list RUN \ apt-get -o Acquire::Check-Valid-Until=false update \ - && apt-get dist-upgrade -y \ && apt-get install -y --no-install-recommends --allow-unauthenticated \ build-essential \ ca-certificates \ diff --git a/go1.14/base/sources-debian10.list b/go1.14/base/sources-debian10.list new file mode 100644 index 00000000..bff91789 --- /dev/null +++ b/go1.14/base/sources-debian10.list @@ -0,0 +1,2 @@ +deb http://deb.debian.org/debian buster main +deb [arch=amd64,i386] http://security.debian.org/debian-security buster/updates main diff --git a/go1.14/base/sources-debian8.list b/go1.14/base/sources-debian8.list index d20d69a1..03a1b7fb 100644 --- a/go1.14/base/sources-debian8.list +++ b/go1.14/base/sources-debian8.list @@ -1,2 +1,2 @@ deb http://archive.debian.org/debian jessie main -deb http://security.debian.org/debian-security jessie/updates main +deb [arch=amd64,i386] http://security.debian.org/debian-security jessie/updates main diff --git a/go1.14/base/sources-debian9.list b/go1.14/base/sources-debian9.list new file mode 100644 index 00000000..449c0aa7 --- /dev/null +++ b/go1.14/base/sources-debian9.list @@ -0,0 +1,2 @@ +deb http://deb.debian.org/debian stretch main +deb [arch=amd64,i386] http://security.debian.org/debian-security stretch/updates main diff --git a/go1.14/darwin/Dockerfile.tmpl b/go1.14/darwin/Dockerfile.tmpl index c5a0048a..5536ef5b 100644 --- a/go1.14/darwin/Dockerfile.tmpl +++ b/go1.14/darwin/Dockerfile.tmpl @@ -1,9 +1,11 @@ ARG REPOSITORY ARG VERSION -FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} RUN \ - apt-get update && apt-get install -y --no-install-recommends --allow-unauthenticated \ + apt-get -o Acquire::Check-Valid-Until=false update \ + && apt-get install -y --no-install-recommends --allow-unauthenticated \ clang \ llvm \ && rm -rf /var/lib/apt/lists/* @@ -28,6 +30,18 @@ ENV PATH $OSXCROSS_PATH/bin:$PATH COPY rootfs / +# Basic test +RUN cd / \ + && o64-clang helloWorld.c -o helloWorld \ + && file helloWorld \ + && file helloWorld | grep -c 'Mach-O 64-bit x86_64' + +RUN cd / \ + && o32-clang helloWorld.c -o helloWorld \ + && file helloWorld \ + && file helloWorld | grep -c 'Mach-O i386' \ + && rm helloWorld.c helloWorld + # Build-time metadata as defined at http://label-schema.org. ARG BUILD_DATE ARG IMAGE diff --git a/go1.14/darwin/rootfs/helloWorld.c b/go1.14/darwin/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go1.14/darwin/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/go1.14/main/Dockerfile.tmpl b/go1.14/main/Dockerfile.tmpl index 24525ecf..86711f84 100644 --- a/go1.14/main/Dockerfile.tmpl +++ b/go1.14/main/Dockerfile.tmpl @@ -1,6 +1,6 @@ ARG REPOSITORY ARG VERSION -ARG TAG_EXTENSION= +ARG TAG_EXTENSION='' FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} RUN \ @@ -22,6 +22,14 @@ RUN \ COPY rootfs / +# Basic test +RUN cd / \ + && gcc helloWorld.c -o helloWorld \ + && file helloWorld \ + && readelf -h helloWorld \ + && file helloWorld | cut -d "," -f 2 | grep -c 'x86-64' \ + && rm helloWorld.c helloWorld + # Build-time metadata as defined at http://label-schema.org. ARG BUILD_DATE ARG IMAGE diff --git a/go1.14/main/rootfs/helloWorld.c b/go1.14/main/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go1.14/main/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/go1.14/mips/Dockerfile.tmpl b/go1.14/mips/Dockerfile.tmpl index 25fe93d6..f03eb5fd 100644 --- a/go1.14/mips/Dockerfile.tmpl +++ b/go1.14/mips/Dockerfile.tmpl @@ -1,10 +1,11 @@ ARG REPOSITORY ARG VERSION -FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} RUN \ dpkg --add-architecture mips64el \ - && apt-get update -qq \ + && apt-get -o Acquire::Check-Valid-Until=false update -qq \ && apt-get install -qq -y \ --no-install-recommends \ --allow-unauthenticated \ @@ -25,10 +26,27 @@ RUN \ libicu57:mips64el \ icu-devtools:mips64el \ libsystemd-dev:mips64el \ + librpm3:mips64el \ + librpmio3:mips64el \ + librpmbuild3:mips64el \ + librpmsign3:mips64el \ + libsqlite3-dev:mips64el \ + libnss3:mips64el \ + libsqlite3-0:mips64el \ && rm -rf /var/lib/apt/lists/* COPY rootfs / +# Basic test +RUN cd / \ + && mips64el-linux-gnuabi64-gcc-6 helloWorld.c -o helloWorld \ + && file helloWorld \ + && readelf -h helloWorld \ + && readelf -h helloWorld | grep -c 'MIPS R3000' \ + && readelf -h helloWorld | grep -c 'ELF64' \ + && readelf -h helloWorld | grep -c "little endian" \ + && rm helloWorld.c helloWorld + # Build-time metadata as defined at http://label-schema.org. ARG BUILD_DATE ARG IMAGE diff --git a/go1.14/mips/rootfs/helloWorld.c b/go1.14/mips/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go1.14/mips/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/go1.14/ppc/Dockerfile.tmpl b/go1.14/ppc/Dockerfile.tmpl index acdc1870..5fe2f40c 100644 --- a/go1.14/ppc/Dockerfile.tmpl +++ b/go1.14/ppc/Dockerfile.tmpl @@ -1,11 +1,12 @@ ARG REPOSITORY ARG VERSION -FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} RUN \ dpkg --add-architecture ppc64el \ - && apt-get update -qq \ - && apt-get install -y -qq \ + && apt-get -o Acquire::Check-Valid-Until=false update -qq \ + && apt-get install -qq -y \ --no-install-recommends \ --allow-unauthenticated \ g++-6-powerpc64-linux-gnu \ @@ -21,10 +22,27 @@ RUN \ libicu57:ppc64el \ icu-devtools:ppc64el \ libsystemd-dev:ppc64el \ + librpm3:ppc64el \ + librpmio3:ppc64el \ + librpmbuild3:ppc64el \ + librpmsign3:ppc64el \ + libsqlite3-dev:ppc64el \ + libnss3:ppc64el \ + libsqlite3-0:ppc64el \ && rm -rf /var/lib/apt/lists/* COPY rootfs / +# Basic test +RUN cd / \ + && powerpc64le-linux-gnu-gcc helloWorld.c -o helloWorld \ + && file helloWorld \ + && readelf -h helloWorld \ + && readelf -h helloWorld | grep -c 'PowerPC64' \ + && readelf -h helloWorld | grep -c 'ELF64' \ + && readelf -h helloWorld | grep -c "little endian" \ + && rm helloWorld.c helloWorld + # Build-time metadata as defined at http://label-schema.org. ARG BUILD_DATE ARG IMAGE diff --git a/go1.14/ppc/rootfs/helloWorld.c b/go1.14/ppc/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go1.14/ppc/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/go1.14/s390x/Dockerfile.tmpl b/go1.14/s390x/Dockerfile.tmpl index 0efefa28..41370c35 100644 --- a/go1.14/s390x/Dockerfile.tmpl +++ b/go1.14/s390x/Dockerfile.tmpl @@ -1,11 +1,12 @@ ARG REPOSITORY ARG VERSION -FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} RUN \ dpkg --add-architecture s390x \ - && apt-get update -qq \ - && apt-get install -y -qq \ + && apt-get -o Acquire::Check-Valid-Until=false update -qq \ + && apt-get install -y \ --no-install-recommends \ --allow-unauthenticated \ g++-s390x-linux-gnu \ @@ -20,10 +21,27 @@ RUN \ libicu57:s390x \ icu-devtools:s390x \ libsystemd-dev:s390x \ + librpm3:s390x \ + librpmio3:s390x \ + librpmbuild3:s390x \ + librpmsign3:s390x \ + libsqlite3-dev:s390x \ + libnss3:s390x \ + libsqlite3-0:s390x \ && rm -rf /var/lib/apt/lists/* COPY rootfs / +# Basic test +RUN cd / \ + && s390x-linux-gnu-gcc helloWorld.c -o helloWorld \ + && file helloWorld \ + && readelf -h helloWorld \ + && readelf -h helloWorld | grep -c 'IBM S/390' \ + && readelf -h helloWorld | grep -c 'ELF64' \ + && readelf -h helloWorld | grep -c "big endian" \ + && rm helloWorld.c helloWorld + # Build-time metadata as defined at http://label-schema.org. ARG BUILD_DATE ARG IMAGE diff --git a/go1.14/s390x/rootfs/helloWorld.c b/go1.14/s390x/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go1.14/s390x/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +}