diff --git a/Jenkinsfile b/Jenkinsfile index 9bdfa096..8956c03a 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}" @@ -12,7 +12,7 @@ pipeline { DOCKER_REGISTRY_SECRET = 'secret/observability-team/ci/docker-registry/prod' REGISTRY = 'docker.elastic.co' STAGING_IMAGE = "${env.REGISTRY}/observability-ci" - GO_VERSION = '1.14.2' + GO_VERSION = '1.15.6' } options { timeout(time: 2, unit: 'HOURS') @@ -25,7 +25,7 @@ pipeline { quietPeriod(10) } triggers { - issueCommentTrigger('(?i).*jenkins\\W+run\\W+(?:the\\W+)?tests(?:\\W+please)?.*') + issueCommentTrigger('(?i)(.*jenkins\\W+run\\W+(?:the\\W+)?tests(?:\\W+please)?.*|/test)') } stages { stage('Checkout') { @@ -35,37 +35,50 @@ 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.14', 'go1.15' + } } - } - } - stage('Release') { - when { - branch 'master' - } - stages { - stage('Publish') { - steps { - withGithubNotify(context: 'Publish') { - publishImages() + stages { + stage('Build') { + steps { + withGithubNotify(context: "Build ${GO_FOLDER} ${MAKEFILE}") { + deleteDir() + unstash 'source' + buildImages() + } + } + } + stage('Staging') { + environment { + REPOSITORY = "${env.STAGING_IMAGE}" + } + steps { + withGithubNotify(context: "Staging ${GO_FOLDER} ${MAKEFILE}") { + // 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' + } + steps { + withGithubNotify(context: "Release ${GO_FOLDER} ${MAKEFILE}") { + publishImages() + } } } } @@ -82,7 +95,7 @@ pipeline { def buildImages(){ withGoEnv(){ dir("${env.BASE_DIR}"){ - sh 'make build' + sh "make -C ${GO_FOLDER} -f ${MAKEFILE} build" } } } @@ -90,6 +103,6 @@ def buildImages(){ def publishImages(){ dockerLogin(secret: "${env.DOCKER_REGISTRY_SECRET}", registry: "${env.REGISTRY}") dir("${env.BASE_DIR}"){ - sh(label: "push docker image to ${env.REPOSITORY}", script: 'make push') + sh(label: "push docker image to ${env.REPOSITORY}", script: "make -C ${GO_FOLDER} -f ${MAKEFILE} push") } } diff --git a/Makefile b/Makefile index b5492b89..c659400e 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,14 @@ -TARGETS=go1.10 go1.11 go1.12 go1.13 go1.14 +TARGETS=go1.10 go1.11 go1.12 go1.13 go1.14 go1.15 build: status=".status.build" build: @echo '0' > ${status} @$(foreach var,$(TARGETS), \ - $(MAKE) -C $(var) $@ || echo '1' > ${status}; \ - $(MAKE) -C $(var) -f Makefile.debian7 $@ || echo '1' > ${status}; \ - $(MAKE) -C $(var) -f Makefile.debian8 $@ || echo '1' > ${status}; \ - $(MAKE) -C $(var) -f Makefile.debian9 $@ || echo '1' > ${status};) + $(MAKE) -C $(var) $@; || echo '1' > ${status}; \ + $(MAKE) -C $(var) -f Makefile.debian7 $@; || echo '1' > ${status}; \ + $(MAKE) -C $(var) -f Makefile.debian8 $@; || echo '1' > ${status}; \ + $(MAKE) -C $(var) -f Makefile.debian9 $@; || echo '1' > ${status}; \ + $(MAKE) -C $(var) -f Makefile.debian10 $@; || echo '1' > ${status};) @make -C fpm $@ || echo '1' > ${status} exit $$(cat ${status}) @@ -19,7 +20,8 @@ push: $(MAKE) -C $(var) $@ || echo '1' > ${status}; \ $(MAKE) -C $(var) -f Makefile.debian7 $@ || echo '1' > ${status}; \ $(MAKE) -C $(var) -f Makefile.debian8 $@ || echo '1' > ${status}; \ - $(MAKE) -C $(var) -f Makefile.debian9 $@ || echo '1' > ${status};) + $(MAKE) -C $(var) -f Makefile.debian9 $@ || echo '1' > ${status}; \ + $(MAKE) -C $(var) -f Makefile.debian10 $@ || echo '1' > ${status};) @make -C fpm $@ || echo '1' > ${status} exit $$(cat ${status}) diff --git a/README.md b/README.md index be7eaf11..a72292ae 100644 --- a/README.md +++ b/README.md @@ -14,17 +14,20 @@ The base image used is Debian 9 (stretch) unless otherwise specified. ## Build Tags -- `1.10.8-main`, `1.11.13-main`, `1.12.12-main`, `1.13.12-main`, `1.14.7` - linux/{amd64,386} and windows/{amd64,386} -- `1.10.8-arm`, `1.11.13-arm`, `1.12.12-arm`, `1.13.12-arm`, `1.14.7` - linux/{armv5,armv6,armv7,arm64} -- `1.10.8-darwin`, `1.11.13-darwin`, `1.12.12-darwin`, `1.13.12-darwin`, `1.14.7` - darwin/{amd64,386} -- `1.10.8-ppc`, `1.11.13-ppc`, `1.12.12-ppc`, `1.13.12-ppc`, `1.14.7` - linux/{ppc64,ppc64le} -- `1.10.8-mips`, `1.11.13-mips`, `1.12.12-mips`, `1.13.12-mips`, `1.14.7` - linux/{mips,mipsle,mips64,mips64le} -- `1.10.8-s390x`, `1.11.13-s390x`, `1.12.12-s390`, `1.13.12-s390`, `1.14.7` - linux/s390x -- `1.10.8-main-debian7`, `1.11.13-main-debian7`, `1.12.12-debian7`, `1.13.12-debian7`, `1.14.7` - linux/{amd64,386} and windows/{amd64,386} (Debian 7 +- `1.10.8-main`, `1.11.13-main`, `1.12.12-main`, `1.13.12-main`, `1.14.12-main`, `1.15.6-main` - linux/{amd64,386} and windows/{amd64,386} +- `1.10.8-arm`, `1.11.13-arm`, `1.12.12-arm`, `1.13.12-arm`, `1.14.12-arm`, `1.15.6-arm` - linux/{armv5,armv6,armv7,arm64} +- `1.10.8-darwin`, `1.11.13-darwin`, `1.12.12-darwin`, `1.13.12-darwin`, `1.14.12-darwin` - darwin/{386} +- `1.10.8-darwin`, `1.11.13-darwin`, `1.12.12-darwin`, `1.13.12-darwin`, `1.14.12-darwin`, `1.15.6-darwin` - darwin/{amd64} +- `1.10.8-ppc`, `1.11.13-ppc`, `1.12.12-ppc`, `1.13.12-ppc`, `1.14.12-ppc`, `1.15.6-ppc` - linux/{ppc64,ppc64le} +- `1.10.8-mips`, `1.11.13-mips`, `1.12.12-mips`, `1.13.12-mips`, `1.14.12-mips`, `1.15.6-mips` - linux/{mips,mipsle,mips64,mips64le} +- `1.10.8-s390x`, `1.11.13-s390x`, `1.12.12-s390`, `1.13.12-s390`, `1.14.12-s390`, `1.15.6-s390` - linux/s390x +- `1.10.8-main-debian7`, `1.11.13-main-debian7`, `1.12.12-debian7`, `1.13.12-debian7`, `1.14.12-debian7`, `1.15.6-debian7` - linux/{amd64,386} and windows/{amd64,386} (Debian 7 uses glibc 2.13 so the resulting binaries (if dynamically linked) have greater compatibility.) -- `1.10.8-main-debian8`, `1.11.13-main-debian8`, `1.12.12-main-debian8`, `1.13.12-debian8`, `1.14.7` - linux/{amd64,386} and windows/{amd64,386} (Debian 8 +- `1.10.8-main-debian8`, `1.11.13-main-debian8`, `1.12.12-main-debian8`, `1.13.12-debian8`, `1.14.12-debian8`, `1.15.6-debian8` - linux/{amd64,386} and windows/{amd64,386} (Debian 8 uses glibc 2.19) +- `1.15.6-debian9` - linux/{amd64,386} and windows/{amd64,386} (Debian 9 uses glibc 2.24) +- `1.15.6-debian10` - linux/{amd64,386} and windows/{amd64,386} (Debian 10 uses glibc 2.28) ## Usage Example 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..b4cedcf7 100644 --- a/go1.14/arm/Dockerfile.tmpl +++ b/go1.14/arm/Dockerfile.tmpl @@ -1,11 +1,10 @@ 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 \ @@ -26,30 +25,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 48bb5216..0421ef3f 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 DEBIAN_VERSION # Replace sources.list in order to use archive.debian.org. -COPY sources-debian{{.DEBIAN_VERSION}}.list /etc/apt/sources.list -{{- end}} +COPY sources-debian${DEBIAN_VERSION}.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..ea5d9656 100644 --- a/go1.14/main/Dockerfile.tmpl +++ b/go1.14/main/Dockerfile.tmpl @@ -1,12 +1,12 @@ ARG REPOSITORY ARG VERSION -ARG TAG_EXTENSION= +ARG TAG_EXTENSION='' FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} RUN \ dpkg --add-architecture i386 \ && apt-get -o Acquire::Check-Valid-Until=false update \ - && apt-get install -y --no-install-recommends --allow-unauthenticated \ + && apt-get install -qq -y --no-install-recommends --allow-unauthenticated \ clang \ g++ \ gcc \ @@ -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..036ee196 100644 --- a/go1.14/mips/Dockerfile.tmpl +++ b/go1.14/mips/Dockerfile.tmpl @@ -1,10 +1,12 @@ 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 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 +27,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..0a89b18c 100644 --- a/go1.14/s390x/Dockerfile.tmpl +++ b/go1.14/s390x/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 s390x \ - && apt-get update -qq \ + && apt-get -o Acquire::Check-Valid-Until=false update -qq \ && apt-get install -y -qq \ --no-install-recommends \ --allow-unauthenticated \ @@ -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; +} diff --git a/go1.15/Makefile b/go1.15/Makefile new file mode 100644 index 00000000..12f52c8b --- /dev/null +++ b/go1.15/Makefile @@ -0,0 +1,10 @@ +IMAGES := base main darwin arm mips ppc s390x + +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.15/Makefile.common b/go1.15/Makefile.common new file mode 100644 index 00000000..cbdb6a2e --- /dev/null +++ b/go1.15/Makefile.common @@ -0,0 +1,26 @@ +SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(SELF_DIR)/../Makefile.common + +NAME := golang-crossbuild +VERSION := 1.15.6 +DEBIAN_VERSION ?= 9 +SUFFIX := -$(shell basename $(CURDIR)) +TAG_EXTENSION ?= + +export DEBIAN_VERSION TAG_EXTENSION + +build: + @echo ">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" + @go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile + @docker build -t "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" \ + --build-arg REPOSITORY=$(REPOSITORY) \ + --build-arg VERSION=$(VERSION) \ + --build-arg DEBIAN_VERSION=$(DEBIAN_VERSION) \ + --build-arg TAG_EXTENSION=$(TAG_EXTENSION) \ + --build-arg IMAGE="$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" \ + --build-arg VCS_REF="$(VCS_REF)" \ + --build-arg VCS_URL="$(VCS_URL)" \ + --build-arg BUILD_DATE="$(BUILD_DATE)" \ + . + +.PHONY: build diff --git a/go1.15/Makefile.debian10 b/go1.15/Makefile.debian10 new file mode 100644 index 00000000..04126feb --- /dev/null +++ b/go1.15/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.15/Makefile.debian7 b/go1.15/Makefile.debian7 new file mode 100644 index 00000000..c94da8a0 --- /dev/null +++ b/go1.15/Makefile.debian7 @@ -0,0 +1,14 @@ +IMAGES := base main +DEBIAN_VERSION := 7 +TAG_EXTENSION := -debian7 + +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.15/Makefile.debian8 b/go1.15/Makefile.debian8 new file mode 100644 index 00000000..11834e52 --- /dev/null +++ b/go1.15/Makefile.debian8 @@ -0,0 +1,15 @@ +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/. +push: + @$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;) + +.PHONY: build push diff --git a/go1.15/Makefile.debian9 b/go1.15/Makefile.debian9 new file mode 100644 index 00000000..26265d60 --- /dev/null +++ b/go1.15/Makefile.debian9 @@ -0,0 +1,14 @@ +IMAGES := base main arm darwin mips ppc s390x +DEBIAN_VERSION := 9 +TAG_EXTENSION := -debian9 + +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.15/arm/.dockerignore b/go1.15/arm/.dockerignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/go1.15/arm/.dockerignore @@ -0,0 +1 @@ +Makefile diff --git a/go1.15/arm/Dockerfile.tmpl b/go1.15/arm/Dockerfile.tmpl new file mode 100644 index 00000000..b4cedcf7 --- /dev/null +++ b/go1.15/arm/Dockerfile.tmpl @@ -0,0 +1,56 @@ +ARG REPOSITORY +ARG VERSION +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} + +RUN \ + dpkg --add-architecture arm64 \ + && 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 \ + linux-libc-dev:arm64 \ + libxml2-dev:arm64 \ + libxml2:arm64 \ + libicu-dev:arm64 \ + libicu57:arm64 \ + icu-devtools:arm64 \ + libsystemd-dev:arm64 \ + 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 +ARG VCS_REF +ARG VCS_URL +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$IMAGE \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.schema-version="1.0" diff --git a/go1.15/arm/Makefile b/go1.15/arm/Makefile new file mode 100644 index 00000000..0a42375f --- /dev/null +++ b/go1.15/arm/Makefile @@ -0,0 +1 @@ +include ../Makefile.common diff --git a/go1.15/arm/rootfs/compilers.yaml b/go1.15/arm/rootfs/compilers.yaml new file mode 100644 index 00000000..6269add7 --- /dev/null +++ b/go1.15/arm/rootfs/compilers.yaml @@ -0,0 +1,17 @@ +--- + +linux: + armv7: + CC: arm-linux-gnueabihf-gcc + CXX: arm-linux-gnueabihf-g++ + armv6: + # Using debian armel for ARMv6. + # This is the same as ARMv5 so it will use softfp instead of hardfp. + CC: arm-linux-gnueabi-gcc + CXX: arm-linux-gnueabi-g++ + armv5: + CC: arm-linux-gnueabi-gcc + CXX: arm-linux-gnueabi-g++ + arm64: + CC: aarch64-linux-gnu-gcc + CXX: aarch64-linux-gnu-g++ diff --git a/go1.15/arm/rootfs/helloWorld.c b/go1.15/arm/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go1.15/arm/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/go1.15/base/.dockerignore b/go1.15/base/.dockerignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/go1.15/base/.dockerignore @@ -0,0 +1 @@ +Makefile diff --git a/go1.15/base/Dockerfile.tmpl b/go1.15/base/Dockerfile.tmpl new file mode 100644 index 00000000..ae126c4b --- /dev/null +++ b/go1.15/base/Dockerfile.tmpl @@ -0,0 +1,51 @@ +ARG DEBIAN_VERSION +FROM debian:${DEBIAN_VERSION} + +ARG DEBIAN_VERSION +# Replace sources.list in order to use archive.debian.org. +COPY sources-debian${DEBIAN_VERSION}.list /etc/apt/sources.list + +RUN \ + apt-get -o Acquire::Check-Valid-Until=false update \ + && apt-get dist-upgrade -y \ + && apt-get install -qq -y --no-install-recommends --allow-unauthenticated \ + build-essential \ + ca-certificates \ + curl \ + git \ + gnupg \ + make \ + file \ + flex \ + bison \ + && rm -rf /var/lib/apt/lists/* + +ARG GOLANG_VERSION=1.15.6 +ARG GOLANG_DOWNLOAD_URL=https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz +ARG GOLANG_DOWNLOAD_SHA256=3918e6cc85e7eaaa6f859f1bdbaac772e7a825b0eb423c63d3ae68b21f84b844 + +RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ + && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ + && tar -C /usr/local -xzf golang.tar.gz \ + && rm golang.tar.gz + +ENV GOPATH /go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH + +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" +WORKDIR $GOPATH + +COPY rootfs / + +# show the GLIBC version +RUN ldd --version + +WORKDIR / +RUN go get -d . \ + && go build -o /crossbuild /entrypoint.go \ + && rm -rf /go/* /root/.cache/* /entrypoint.go + +ENV GOLANG_CROSSBUILD=1 +VOLUME /app +WORKDIR /app +ENTRYPOINT ["/crossbuild"] diff --git a/go1.15/base/Makefile b/go1.15/base/Makefile new file mode 100644 index 00000000..0a42375f --- /dev/null +++ b/go1.15/base/Makefile @@ -0,0 +1 @@ +include ../Makefile.common diff --git a/go1.15/base/rootfs/entrypoint.go b/go1.15/base/rootfs/entrypoint.go new file mode 100644 index 00000000..0e5c2985 --- /dev/null +++ b/go1.15/base/rootfs/entrypoint.go @@ -0,0 +1,175 @@ +// +build linux + +package main + +import ( + "fmt" + "io" + "io/ioutil" + "log" + "os" + "os/exec" + "sort" + "strings" + + "github.com/spf13/cobra" + "gopkg.in/yaml.v2" +) + +var rootCmd = &cobra.Command{ + Use: "crossbuild", + Short: "crossbuild is simple tool for cross-compiling Go binaries", + Long: `crossbuild is a containerized tool for cross-compiling Go binaries +by mounting the project inside of a container equipped with cross-compilers. + +The root of your project's repo should be mounted at the appropriate location +on the GOPATH which is set to /go. + +While executing the build command the following variables with be added to the +environment: GOOS, GOARCH, GOARM, PLATFORM_ID, CC, and CXX. +`, + RunE: doBuild, + SilenceUsage: true, +} + +func init() { + rootCmd.PersistentFlags().StringVarP(&buildCommand, "build-cmd", "c", + "make build", "Build command to execute.") + + rootCmd.PersistentFlags().StringSliceVarP(&platforms, "platforms", "p", nil, + "Target platform for the binary in GOOS/GOARCH format (e.g. windows/amd64).") + rootCmd.MarkPersistentFlagRequired("platforms") +} + +func main() { + log.SetFlags(0) + + if err := rootCmd.Execute(); err != nil { + log.Fatal(err) + } +} + +var ( + buildCommand string + platforms []string +) + +func doBuild(_ *cobra.Command, _ []string) error { + for _, p := range platforms { + env, err := buildEnvironment(p) + if err != nil { + return fmt.Errorf("failed constructing the build environment for %v: %v", p, err) + } + + if err = execBuildCommand(env); err != nil { + return fmt.Errorf("failed building for %v: %v", p, err) + } + } + + return nil +} + +func isDirEmpty(name string) (bool, error) { + f, err := os.Open(name) + if err != nil { + return false, err + } + defer f.Close() + + _, err = f.Readdirnames(1) + if err == io.EOF { + return true, nil + } + return false, err +} + +func buildEnvironment(platform string) (map[string]string, error) { + parts := strings.SplitN(platform, "/", 2) + if len(parts) != 2 { + return nil, fmt.Errorf("invalid platform %v", platform) + } + + platformID := strings.Join(parts, "-") + goos := parts[0] + arch := parts[1] + goarch := arch + goarm := "" + + if strings.HasPrefix(arch, "armv") { + goarch = "arm" + goarm = strings.TrimPrefix(arch, "armv") + } + + env := map[string]string{ + "GOOS": goos, + "GOARCH": goarch, + "GOARM": goarm, + "PLATFORM_ID": platformID, + } + + if err := loadCompilerSettings(goos, arch, env); err != nil { + return nil, fmt.Errorf("failed while loading compiler settings: %v", err) + } + + return env, nil +} + +type Compilers struct { + GOOS map[string]struct { + Arch map[string]struct { + Env map[string]string `yaml:",inline"` + } `yaml:",inline"` + } `yaml:",inline"` +} + +func loadCompilerSettings(goos, arch string, env map[string]string) error { + data, err := ioutil.ReadFile("/compilers.yaml") + if err != nil { + if os.IsNotExist(err) { + return nil + } + return fmt.Errorf("failed to read /compilers.yaml: %v", err) + } + + var compilers Compilers + if err = yaml.Unmarshal(data, &compilers); err != nil { + return fmt.Errorf("failed to parse /compilers.yaml: %v", err) + } + + arches, found := compilers.GOOS[goos] + if !found { + return fmt.Errorf("%v is not supported by this image", goos) + } + + settings, found := arches.Arch[arch] + if !found { + return fmt.Errorf("%v/%v is not supported by this image", goos, arch) + } + + for k, v := range settings.Env { + env[k] = v + } + + return nil +} + +func execBuildCommand(env map[string]string) error { + cmd := exec.Command("sh", "-c", buildCommand) + cmd.Env = os.Environ() + logEnv := make([]string, 0, len(env)) + for k, v := range env { + kv := k + "=" + v + cmd.Env = append(cmd.Env, kv) + logEnv = append(logEnv, kv) + } + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Stdin = os.Stdin + + var b strings.Builder + sort.Strings(logEnv) + fmt.Fprintf(&b, ">> Building using: cmd='%v', env=[%v]", buildCommand, strings.Join(logEnv, ", ")) + + log.Println(b.String()) + return cmd.Run() +} diff --git a/go1.15/base/sources-debian10.list b/go1.15/base/sources-debian10.list new file mode 100644 index 00000000..bff91789 --- /dev/null +++ b/go1.15/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.15/base/sources-debian7.list b/go1.15/base/sources-debian7.list new file mode 100644 index 00000000..18c86e1e --- /dev/null +++ b/go1.15/base/sources-debian7.list @@ -0,0 +1,2 @@ +deb http://archive.debian.org/debian wheezy main +deb http://archive.debian.org/debian-security wheezy/updates main diff --git a/go1.15/base/sources-debian8.list b/go1.15/base/sources-debian8.list new file mode 100644 index 00000000..03a1b7fb --- /dev/null +++ b/go1.15/base/sources-debian8.list @@ -0,0 +1,2 @@ +deb http://archive.debian.org/debian jessie main +deb [arch=amd64,i386] http://security.debian.org/debian-security jessie/updates main diff --git a/go1.15/base/sources-debian9.list b/go1.15/base/sources-debian9.list new file mode 100644 index 00000000..449c0aa7 --- /dev/null +++ b/go1.15/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.15/darwin/Dockerfile.tmpl b/go1.15/darwin/Dockerfile.tmpl new file mode 100644 index 00000000..f1bf226a --- /dev/null +++ b/go1.15/darwin/Dockerfile.tmpl @@ -0,0 +1,54 @@ +ARG REPOSITORY +ARG VERSION +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} + +RUN \ + apt-get -o Acquire::Check-Valid-Until=false update \ + && apt-get install -qq -y --no-install-recommends --allow-unauthenticated \ + clang \ + llvm \ + && rm -rf /var/lib/apt/lists/* + +ARG OSXCROSS_SDK_URL=https://s3.amazonaws.com/beats-files/deps/MacOSX10.11.sdk.tar.xz +ARG OSXCROSS_PATH=/usr/osxcross +ARG OSXCROSS_REV=3034f7149716d815bc473d0a7b35d17e4cf175aa +ARG SDK_VERSION=10.11 +ARG DARWIN_VERSION=15 +ARG OSX_VERSION_MIN=10.10 + +RUN \ + mkdir -p /tmp/osxcross && cd /tmp/osxcross \ + && curl -sSL "https://codeload.github.com/tpoechtrager/osxcross/tar.gz/${OSXCROSS_REV}" \ + | tar -C /tmp/osxcross --strip=1 -xzf - \ + && curl -sSLo "tarballs/MacOSX${SDK_VERSION}.sdk.tar.xz" "${OSXCROSS_SDK_URL}" \ + && UNATTENDED=yes ./build.sh >/dev/null \ + && mv target "${OSXCROSS_PATH}" \ + && rm -rf /tmp/osxcross "/usr/osxcross/SDK/MacOSX${SDK_VERSION}.sdk/usr/share/man" + +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 +ARG VCS_REF +ARG VCS_URL +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$IMAGE \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.schema-version="1.0" diff --git a/go1.15/darwin/Makefile b/go1.15/darwin/Makefile new file mode 100644 index 00000000..0a42375f --- /dev/null +++ b/go1.15/darwin/Makefile @@ -0,0 +1 @@ +include ../Makefile.common diff --git a/go1.15/darwin/rootfs/compilers.yaml b/go1.15/darwin/rootfs/compilers.yaml new file mode 100644 index 00000000..23645ab9 --- /dev/null +++ b/go1.15/darwin/rootfs/compilers.yaml @@ -0,0 +1,6 @@ +--- + +darwin: + amd64: + CC: o64-clang + CXX: o64-clang++ diff --git a/go1.15/darwin/rootfs/helloWorld.c b/go1.15/darwin/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go1.15/darwin/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/go1.15/main/.dockerignore b/go1.15/main/.dockerignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/go1.15/main/.dockerignore @@ -0,0 +1 @@ +Makefile diff --git a/go1.15/main/Dockerfile.tmpl b/go1.15/main/Dockerfile.tmpl new file mode 100644 index 00000000..ea5d9656 --- /dev/null +++ b/go1.15/main/Dockerfile.tmpl @@ -0,0 +1,42 @@ +ARG REPOSITORY +ARG VERSION +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} + +RUN \ + dpkg --add-architecture i386 \ + && apt-get -o Acquire::Check-Valid-Until=false update \ + && apt-get install -qq -y --no-install-recommends --allow-unauthenticated \ + clang \ + g++ \ + gcc \ + gcc-multilib \ + libc6-dev \ + libc6-dev-i386 \ + linux-libc-dev:i386 \ + mingw-w64 \ + mingw-w64-tools \ + patch \ + xz-utils \ + && rm -rf /var/lib/apt/lists/* + +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 +ARG VCS_REF +ARG VCS_URL +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$IMAGE \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.schema-version="1.0" diff --git a/go1.15/main/Makefile b/go1.15/main/Makefile new file mode 100644 index 00000000..0a42375f --- /dev/null +++ b/go1.15/main/Makefile @@ -0,0 +1 @@ +include ../Makefile.common diff --git a/go1.15/main/rootfs/compilers.yaml b/go1.15/main/rootfs/compilers.yaml new file mode 100644 index 00000000..02af3c42 --- /dev/null +++ b/go1.15/main/rootfs/compilers.yaml @@ -0,0 +1,25 @@ +--- + +windows: + 386: + CC: i686-w64-mingw32-gcc + CXX: i686-w64-mingw32-g++ + amd64: + CC: x86_64-w64-mingw32-gcc + CXX: x86_64-w64-mingw32-g++ + +darwin: + 386: + CC: o32-clang + CXX: o32-clang++ + amd64: + CC: o64-clang + CXX: o64-clang++ + +linux: + 386: + CC: gcc + CXX: g++ + amd64: + CC: gcc + CXX: g++ diff --git a/go1.15/main/rootfs/helloWorld.c b/go1.15/main/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go1.15/main/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/go1.15/mips/.dockerignore b/go1.15/mips/.dockerignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/go1.15/mips/.dockerignore @@ -0,0 +1 @@ +Makefile diff --git a/go1.15/mips/Dockerfile.tmpl b/go1.15/mips/Dockerfile.tmpl new file mode 100644 index 00000000..036ee196 --- /dev/null +++ b/go1.15/mips/Dockerfile.tmpl @@ -0,0 +1,60 @@ +ARG REPOSITORY +ARG VERSION +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} + +RUN apt-get update +RUN \ + dpkg --add-architecture mips64el \ + && apt-get -o Acquire::Check-Valid-Until=false update -qq \ + && apt-get install -qq -y \ + --no-install-recommends \ + --allow-unauthenticated \ + crossbuild-essential-mipsel \ + gcc-mips-linux-gnu \ + g++-mips-linux-gnu \ + gcc-6-mips64-linux-gnuabi64 \ + g++-6-mips64-linux-gnuabi64 \ + gcc-6-mips64el-linux-gnuabi64 \ + g++-6-mips64el-linux-gnuabi64 \ + librpm-dev:mips64el \ + libc-dev:mips64el \ + libpopt-dev:mips64el \ + linux-libc-dev:mips64el \ + libxml2-dev:mips64el \ + libxml2:mips64el \ + libicu-dev:mips64el \ + 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 +ARG VCS_REF +ARG VCS_URL +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$IMAGE \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.schema-version="1.0" diff --git a/go1.15/mips/Makefile b/go1.15/mips/Makefile new file mode 100644 index 00000000..0a42375f --- /dev/null +++ b/go1.15/mips/Makefile @@ -0,0 +1 @@ +include ../Makefile.common diff --git a/go1.15/mips/rootfs/compilers.yaml b/go1.15/mips/rootfs/compilers.yaml new file mode 100644 index 00000000..7dff3130 --- /dev/null +++ b/go1.15/mips/rootfs/compilers.yaml @@ -0,0 +1,15 @@ +--- + +linux: + mips: + CC: mips-linux-gnu-gcc + CXX: mips-linux-gnu-g++ + mipsle: + CC: mipsel-linux-gnu-gcc + CXX: mipsel-linux-gnu-g++ + mips64: + CC: mips64-linux-gnuabi64-gcc-6 + CXX: mips64-linux-gnuabi64-g++-6 + mips64le: + CC: mips64el-linux-gnuabi64-gcc-6 + CXX: mips64el-linux-gnuabi64-g++-6 diff --git a/go1.15/mips/rootfs/helloWorld.c b/go1.15/mips/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go1.15/mips/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/go1.15/ppc/.dockerignore b/go1.15/ppc/.dockerignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/go1.15/ppc/.dockerignore @@ -0,0 +1 @@ +Makefile diff --git a/go1.15/ppc/Dockerfile.tmpl b/go1.15/ppc/Dockerfile.tmpl new file mode 100644 index 00000000..5fe2f40c --- /dev/null +++ b/go1.15/ppc/Dockerfile.tmpl @@ -0,0 +1,55 @@ +ARG REPOSITORY +ARG VERSION +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} + +RUN \ + dpkg --add-architecture ppc64el \ + && 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 \ + gcc-6-powerpc64-linux-gnu \ + crossbuild-essential-ppc64el \ + librpm-dev:ppc64el \ + libc-dev:ppc64el \ + libpopt-dev:ppc64el \ + linux-libc-dev:ppc64el \ + libxml2-dev:ppc64el \ + libxml2:ppc64el \ + libicu-dev:ppc64el \ + 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 +ARG VCS_REF +ARG VCS_URL +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$IMAGE \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.schema-version="1.0" diff --git a/go1.15/ppc/Makefile b/go1.15/ppc/Makefile new file mode 100644 index 00000000..0a42375f --- /dev/null +++ b/go1.15/ppc/Makefile @@ -0,0 +1 @@ +include ../Makefile.common diff --git a/go1.15/ppc/rootfs/compilers.yaml b/go1.15/ppc/rootfs/compilers.yaml new file mode 100644 index 00000000..15ab651f --- /dev/null +++ b/go1.15/ppc/rootfs/compilers.yaml @@ -0,0 +1,9 @@ +--- + +linux: + ppc64: + CC: powerpc64-linux-gnu-gcc-6 + CXX: powerpc64-linux-gnu-g++-6 + ppc64le: + CC: powerpc64le-linux-gnu-gcc + CXX: powerpc64le-linux-gnu-g++ diff --git a/go1.15/ppc/rootfs/helloWorld.c b/go1.15/ppc/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go1.15/ppc/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/go1.15/s390x/.dockerignore b/go1.15/s390x/.dockerignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/go1.15/s390x/.dockerignore @@ -0,0 +1 @@ +Makefile diff --git a/go1.15/s390x/Dockerfile.tmpl b/go1.15/s390x/Dockerfile.tmpl new file mode 100644 index 00000000..0a89b18c --- /dev/null +++ b/go1.15/s390x/Dockerfile.tmpl @@ -0,0 +1,54 @@ +ARG REPOSITORY +ARG VERSION +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} + +RUN \ + dpkg --add-architecture s390x \ + && apt-get -o Acquire::Check-Valid-Until=false update -qq \ + && apt-get install -y -qq \ + --no-install-recommends \ + --allow-unauthenticated \ + g++-s390x-linux-gnu \ + gcc-s390x-linux-gnu \ + librpm-dev:s390x \ + libc-dev:s390x \ + libpopt-dev:s390x \ + linux-libc-dev:s390x \ + libxml2-dev:s390x \ + libxml2:s390x \ + libicu-dev:s390x \ + 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 +ARG VCS_REF +ARG VCS_URL +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$IMAGE \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.schema-version="1.0" diff --git a/go1.15/s390x/Makefile b/go1.15/s390x/Makefile new file mode 100644 index 00000000..0a42375f --- /dev/null +++ b/go1.15/s390x/Makefile @@ -0,0 +1 @@ +include ../Makefile.common diff --git a/go1.15/s390x/rootfs/compilers.yaml b/go1.15/s390x/rootfs/compilers.yaml new file mode 100644 index 00000000..22ae10ab --- /dev/null +++ b/go1.15/s390x/rootfs/compilers.yaml @@ -0,0 +1,6 @@ +--- + +linux: + s390x: + CC: s390x-linux-gnu-gcc + CXX: s390x-linux-gnu-g++ diff --git a/go1.15/s390x/rootfs/helloWorld.c b/go1.15/s390x/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go1.15/s390x/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +}