Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update golang to 1.15.5 #72

Merged
merged 25 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a33428f
fix: back to Debian 7
kuisathaverat Jul 31, 2020
1b85007
Merge branch 'master' of github.com:elastic/golang-crossbuild into de…
kuisathaverat Oct 2, 2020
b743fe0
fix: support x86 on Debian7
kuisathaverat Oct 2, 2020
3b819e8
Add support for Golang 1.15.4
kvch Nov 9, 2020
4ddc5ca
tmp
kvch Nov 10, 2020
3e9c4e6
Merge branch 'debian-7' of github.com:kuisathaverat/golang-crossbuild…
kuisathaverat Dec 3, 2020
065a228
feat: add test comment
kuisathaverat Dec 3, 2020
55db4c5
fix: set default Debian9
kuisathaverat Dec 3, 2020
7478311
fix: restore other ARM compilers
kuisathaverat Dec 3, 2020
f0d57d5
fix: get sources list depending on the Debian version
kuisathaverat Dec 3, 2020
27c82a6
chore: minor changes
kuisathaverat Dec 3, 2020
397dddf
fix: support for go 1.15
kuisathaverat Dec 3, 2020
c763637
Merge branch 'master' into update-golang-to-1.15.4
kuisathaverat Dec 3, 2020
fe50a3c
Update Makefile
kuisathaverat Dec 3, 2020
9dcdb37
Update Makefile
kuisathaverat Dec 3, 2020
db60968
fix: typo
kuisathaverat Dec 3, 2020
b4ef7d8
Merge branch 'update-golang-to-1.15.4' of github.com:kuisathaverat/go…
kuisathaverat Dec 3, 2020
3b0ec80
fix: push correct images
kuisathaverat Dec 3, 2020
a6fa219
fix: use single quotes
kuisathaverat Dec 3, 2020
248d0e7
fix: update go to 1.15.5
kuisathaverat Dec 3, 2020
ee52e77
chore: refactor jenkinsfile
kuisathaverat Jan 5, 2021
9c6d169
docs: update tags documentation
kuisathaverat Jan 5, 2021
a01af90
chore: bump Go version to 1.15.6
kuisathaverat Jan 5, 2021
c54ef11
feta: show GLIB version in logs
kuisathaverat Jan 5, 2021
565ac72
chore: suggested change
kuisathaverat Jan 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 52 additions & 35 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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.5'
kuisathaverat marked this conversation as resolved.
Show resolved Hide resolved
}
options {
timeout(time: 2, unit: 'HOURS')
Expand All @@ -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') {
Expand All @@ -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.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'
}
stages {
stage('Publish') {
steps {
withGithubNotify(context: "Publish ${GO_FOLDER} ${MAKEFILE}") {
publishImages()
}
}
}
kuisathaverat marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand All @@ -82,14 +99,14 @@ pipeline {
def buildImages(){
withGoEnv(){
dir("${env.BASE_DIR}"){
sh 'make build'
sh "make -C ${GO_FOLDER} -f ${MAKEFILE} build"
}
}
}

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")
}
}
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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})

Expand All @@ -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})

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ 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.7-main`, `1.15.4-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.7-arm`, `1.15.4-arm` - 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`, `1.15.3-darwin/amd64` - darwin/{amd64,386}
kuisathaverat marked this conversation as resolved.
Show resolved Hide resolved
- `1.10.8-ppc`, `1.11.13-ppc`, `1.12.12-ppc`, `1.13.12-ppc`, `1.14.7-ppc`, `1.15.4-ppc` - linux/{ppc64,ppc64le}
- `1.10.8-mips`, `1.11.13-mips`, `1.12.12-mips`, `1.13.12-mips`, `1.14.7-mips`, `1.15.4-mips` - linux/{mips,mipsle,mips64,mips64le}
- `1.10.8-s390x`, `1.11.13-s390x`, `1.12.12-s390`, `1.13.12-s390`, `1.14.7-s390`, `1.15.4-s390` - linux/s390x
- `1.10.8-main-debian7`, `1.11.13-main-debian7`, `1.12.12-debian7`, `1.13.12-debian7`, `1.14.7-debian7`, `1.15.4-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.7-debian8`, `1.15.4-debian8` - linux/{amd64,386} and windows/{amd64,386} (Debian 8
uses glibc 2.19)

## Usage Example
Expand Down
14 changes: 14 additions & 0 deletions go1.14/Makefile.debian10
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion go1.14/Makefile.debian8
Original file line number Diff line number Diff line change
@@ -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/.
Expand Down
2 changes: 1 addition & 1 deletion go1.14/Makefile.debian9
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
IMAGES := base main
IMAGES := base main arm darwin mips ppc s390x
DEBIAN_VERSION := 9
TAG_EXTENSION := -debian9

Expand Down
40 changes: 17 additions & 23 deletions go1.14/arm/Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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

kuisathaverat marked this conversation as resolved.
Show resolved Hide resolved
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
Expand Down
5 changes: 5 additions & 0 deletions go1.14/arm/rootfs/helloWorld.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
6 changes: 2 additions & 4 deletions go1.14/base/Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
2 changes: 2 additions & 0 deletions go1.14/base/sources-debian10.list
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion go1.14/base/sources-debian8.list
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions go1.14/base/sources-debian9.list
Original file line number Diff line number Diff line change
@@ -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
18 changes: 16 additions & 2 deletions go1.14/darwin/Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -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/*
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions go1.14/darwin/rootfs/helloWorld.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
12 changes: 10 additions & 2 deletions go1.14/main/Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ARG REPOSITORY
ARG VERSION
ARG TAG_EXTENSION=
ARG TAG_EXTENSION
kuisathaverat marked this conversation as resolved.
Show resolved Hide resolved
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 \
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions go1.14/main/rootfs/helloWorld.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
Loading