You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
4.5 KiB
148 lines
4.5 KiB
// Jenkins file to build our dev docker images based on alpine, debian & ubuntu |
|
properties( [ |
|
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '7', numToKeepStr: '10')), |
|
disableConcurrentBuilds(), |
|
disableResume(), |
|
pipelineTriggers([cron('H H * * *')]) |
|
]) |
|
|
|
// Repository name use, must end with / or be '' for none |
|
repository= 'docker.ceres.area51.dev/area51/' |
|
|
|
// Architectures to build images |
|
AMD64 = 'amd64' |
|
ARM64 = 'arm64v8' |
|
ARM32 = 'arm32v7' |
|
architectures = [ AMD64, ARM64, ARM32 ] |
|
|
|
// Predicates for architectures |
|
def targetAny = { target -> true } |
|
def targetNotArm32 = { target -> target != ARM32 } |
|
|
|
// The tools to build |
|
// target is the docker target to build this tool |
|
// label is shown in the build logs |
|
// include = predicate to filter out tools not compilable on a platform |
|
tools = [ |
|
[ target:"asmx", label:"asmx Assembler", include: targetAny ], |
|
[ target:"beebasm", label:"beebasm Assembler", include: targetAny ], |
|
[ target:"dasm", label:"dasm Assembler", include: targetAny ], |
|
[ target:"z88dk", label:"z88dk Z80 C compiler & Assembler", include: targetAny ], |
|
// beebjit currently fails on ARM32 with a warning in the sound driver |
|
[ target:"beebjit", label:"beebjit BBC Micro Emulator", include: targetNotArm32 ], |
|
[ target:"tools", label:"disk image tool", include: targetAny ], |
|
] |
|
|
|
// The go arch |
|
def goarch = { |
|
architecture -> switch( architecture ) { |
|
case 'amd64': |
|
return 'amd64' |
|
case 'arm32v6': |
|
case 'arm32v7': |
|
return 'arm' |
|
case 'arm64v8': |
|
return 'arm64' |
|
default: |
|
return architecture |
|
} |
|
} |
|
|
|
// The go arch variant |
|
def goVariant = { |
|
architecture -> switch( architecture ) { |
|
case 'arm32v6': |
|
return '6' |
|
case 'arm32v7': |
|
return '7' |
|
default: |
|
return '""' |
|
} |
|
} |
|
|
|
def dockerTag2 = { |
|
tag -> 'docker.ceres.area51.dev/area51/dev8bit:' + tag |
|
} |
|
|
|
def dockerTag = { |
|
architecture -> dockerTag2( architecture + '-latest' ) |
|
} |
|
|
|
def dockerBuild = { |
|
architecture, target -> [ |
|
'./buildStep.sh', |
|
target, |
|
architecture, |
|
goarch( architecture ), |
|
goVariant( architecture ), |
|
dockerTag(architecture) |
|
].join(' ') |
|
} |
|
|
|
targets = [:] |
|
architectures.each { |
|
architecture -> targets[architecture] = { |
|
node( architecture) { |
|
stage( "Prepare" ) { |
|
// Checkout project & pull relevant images |
|
checkout scm |
|
sh label: "Pull dev image", script: dockerBuild(architecture,'dev') |
|
sh label: "Pull golang image", script: dockerBuild(architecture,'goDev') |
|
} |
|
|
|
stage( "Base Image") { |
|
// Base image with X11 support |
|
sh label: "Install xvfb", script: dockerBuild(architecture,'base') |
|
} |
|
|
|
stage( "Fetch sources" ) { |
|
sh dockerBuild(architecture,'src') |
|
} |
|
|
|
tools.each { |
|
target -> L:{ |
|
if( target.include( architecture ) ) { |
|
stage( target.target ) { |
|
sh label: target.label, script: dockerBuild(architecture, target.target) |
|
} |
|
} |
|
} |
|
} |
|
|
|
stage( "Push" ) { |
|
sh label: 'Push ' + architecture +' image', script: 'docker push ' + dockerTag(architecture) |
|
} |
|
} |
|
} |
|
} |
|
|
|
stage( "Build" ) { |
|
parallel targets |
|
} |
|
|
|
stage( "MultiArch" ) { |
|
node( "amd64" ) { |
|
stage( "MultiArch" ) { |
|
def multiImage = dockerTag2( 'latest' ) |
|
|
|
architectures.each { |
|
architecture -> sh label: "Pull " + architecture, script: 'docker pull ' + dockerTag( architecture ) |
|
} |
|
|
|
sh label: "Create manifest", script: 'docker manifest create ' + multiImage + ' ' + architectures.collect { architecture -> dockerTag( architecture ) } .join(' ') |
|
|
|
architectures.each { |
|
architecture -> sh label: "Annotate " + architecture, script: [ |
|
'docker manifest annotate', |
|
'--os linux', |
|
'--arch', goarch( architecture ), |
|
goVariant( architecture ) == '' ? '' : '--variant v' + goVariant( architecture ), |
|
multiImage, |
|
dockerTag( architecture ) |
|
].join(' ') |
|
} |
|
|
|
sh label: "Push manifest", script: 'docker manifest push -p ' + multiImage |
|
} |
|
} |
|
} |