Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
81 changes: 49 additions & 32 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 Down Expand Up @@ -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()
}
}
}
}
}
}
Expand All @@ -82,7 +99,7 @@ pipeline {
def buildImages(){
withGoEnv(){
dir("${env.BASE_DIR}"){
sh 'make build'
sh 'make -c ${GO_FOLDER} -f ${MAKEFILE} build'
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/.
Expand All @@ -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
2 changes: 1 addition & 1 deletion go1.14/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?=

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
44 changes: 17 additions & 27 deletions go1.14/arm/Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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
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 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 \
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;
}
10 changes: 9 additions & 1 deletion go1.14/main/Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG REPOSITORY
ARG VERSION
ARG TAG_EXTENSION=
ARG TAG_EXTENSION=''
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}

RUN \
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;
}
22 changes: 20 additions & 2 deletions go1.14/mips/Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions go1.14/mips/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