use our library
This commit is contained in:
parent
0f4d12e2a5
commit
5d2f6b433f
53
Jenkinsfile
vendored
53
Jenkinsfile
vendored
@ -1,55 +1,4 @@
|
||||
def buildAndPush() {
|
||||
// env.ARCH is the system architecture. some apps can be generic (amd64, arm64),
|
||||
// but apps that compile for specific hardware (like web3-proxy) will need more specific tags (amd64_epyc2, arm64_graviton2, intel_xeon3, etc.)
|
||||
// env.BRANCH_NAME is set to the git branch name by default
|
||||
// env.REGISTRY is the repository url for this pipeline
|
||||
// env.GIT_SHORT is the git short hash of the currently checked out repo
|
||||
// env.LATEST_BRANCH is the branch name that gets tagged latest
|
||||
|
||||
// TODO: check that this system actually matches the given arch
|
||||
sh '''#!/bin/bash
|
||||
set -eux -o pipefail
|
||||
|
||||
[ -n "$ARCH" ]
|
||||
[ -n "$BRANCH_NAME" ]
|
||||
[ -n "$REGISTRY" ]
|
||||
[ -n "$GIT_SHORT" ]
|
||||
[ -n "$LATEST_BRANCH" ]
|
||||
|
||||
# deterministic mtime on .git keeps Dockerfiles that do 'ADD . .' or similar
|
||||
# without this, the build process always thinks the directory has changes
|
||||
git restore-mtime
|
||||
touch -t "$(git show -s --date=format:'%Y%m%d%H%M.%S' --format=%cd HEAD)" .git
|
||||
|
||||
function buildAndPush {
|
||||
image=$1
|
||||
buildcache=$2
|
||||
|
||||
buildctl build \
|
||||
--frontend=dockerfile.v0 \
|
||||
--local context=. \
|
||||
--local dockerfile=. \
|
||||
--output "type=image,name=${image},push=true" \
|
||||
--export-cache type=s3,region=us-east-2,bucket=llamarpc-buildctl-cache,name=${buildcache} \
|
||||
--import-cache type=s3,region=us-east-2,bucket=llamarpc-buildctl-cache,name=${buildcache} \
|
||||
;
|
||||
}
|
||||
|
||||
BUILDCACHE="${REGISTRY}:buildcache_${ARCH}"
|
||||
|
||||
# build and push a docker image tagged with the short git commit
|
||||
buildAndPush "${REGISTRY}:git_${GIT_SHORT}_${ARCH}" "${BUILDCACHE}"
|
||||
|
||||
# push an image tagged with the branch
|
||||
# since buildAndPush just ran above, this should be very quick
|
||||
# TODO: maybe replace slashes in the name with dashes or underscores
|
||||
buildAndPush "${REGISTRY}:branch_${BRANCH_NAME}_${ARCH}" "${BUILDCACHE}"
|
||||
|
||||
if [ "${BRANCH_NAME}" = "${LATEST_BRANCH}" ]; then
|
||||
buildAndPush "${REGISTRY}:latest_${ARCH}" "${BUILDCACHE}"
|
||||
fi
|
||||
'''
|
||||
}
|
||||
@Library('jenkins_lib@main') _
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
|
Loading…
Reference in New Issue
Block a user