-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from DARPA-ASKEM/146-add-circleci-support
add circleci support
- Loading branch information
Showing
3 changed files
with
132 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
version: 2.1 | ||
|
||
executors: | ||
amd64: | ||
docker: | ||
- image: cimg/base:current | ||
resource_class: large | ||
environment: | ||
PLATFORM: "linux/amd64" | ||
EXECUTOR: "amd64" | ||
arm64: | ||
docker: | ||
- image: cimg/base:current | ||
resource_class: arm.large | ||
environment: | ||
PLATFORM: "linux/arm64" | ||
EXECUTOR: "arm64" | ||
|
||
commands: | ||
configure-ghcr: | ||
description: Configure GHCR access | ||
steps: | ||
- run: | ||
name: Configure GHCR | ||
command: | | ||
[ -z "$GHCR_TOKEN" ] && exit 0 | ||
[ -z "$GHCR_USER" ] && exit 0 | ||
for i in $(seq 1 5); do | ||
echo "Logging into GHCR, attempt $i" | ||
echo $GHCR_TOKEN | docker login ghcr.io -u $GHCR_USER --password-stdin && break | ||
sleep 1 | ||
done | ||
tag-generator: | ||
description: Format CIRCLE_TAG | ||
steps: | ||
- run: | ||
name: Generate environment variables for build | ||
command: | | ||
if [ -n "${CIRCLE_TAG}" ]; then | ||
SEMVER=$( echo ${CIRCLE_TAG} | sed -nre 's/^v[^0-9]*(([0-9]+\.)*[0-9]+(-[a-z]+)?).*/\1/p') | ||
if [[ -n $SEMVER ]]; then | ||
IMAGE_TAG=${SEMVER} | ||
else | ||
IMAGE_TAG=${CIRCLE_TAG} | ||
fi | ||
else | ||
IMAGE_TAG=latest | ||
fi | ||
echo -e "export DOCKER_REGISTRY=ghcr.io\n" >> $BASH_ENV | ||
echo -e "export DOCKER_ORG=darpa-askem\n" >> $BASH_ENV | ||
echo -e "export PACKAGE_NAME=beaker-kernel\n" >> $BASH_ENV | ||
echo -e "export IMAGE_TAG=${IMAGE_TAG}\n" >> $BASH_ENV | ||
source $BASH_ENV | ||
jobs: | ||
build-push-light: | ||
parameters: | ||
platform: | ||
type: executor | ||
executor: << parameters.platform >> | ||
steps: | ||
- checkout | ||
- setup_remote_docker | ||
- configure-ghcr | ||
- tag-generator | ||
- run: | ||
name: "Light Build" | ||
command: | | ||
export VERSION=${IMAGE_TAG}-${EXECUTOR} | ||
echo "Building image: ${DOCKER_REGISTRY}/${DOCKER_ORG}/${PACKAGE_NAME}:${VERSION}" | ||
docker build -f Dockerfile.light -t ${DOCKER_REGISTRY}/${DOCKER_ORG}/${PACKAGE_NAME}:${VERSION} . | ||
docker push ${DOCKER_REGISTRY}/${DOCKER_ORG}/${PACKAGE_NAME}:${VERSION} | ||
build-push-full: | ||
parameters: | ||
platform: | ||
type: executor | ||
executor: << parameters.platform >> | ||
steps: | ||
- checkout | ||
- setup_remote_docker | ||
- configure-ghcr | ||
- tag-generator | ||
- run: | ||
name: "Full Build" | ||
command: | | ||
export VERSION=${IMAGE_TAG}-${EXECUTOR} | ||
echo "Building image: ${DOCKER_REGISTRY}/${DOCKER_ORG}/${PACKAGE_NAME}:${VERSION}" | ||
docker build -f Dockerfile.full -t ${DOCKER_REGISTRY}/${DOCKER_ORG}/${PACKAGE_NAME}:${VERSION} . | ||
docker push ${DOCKER_REGISTRY}/${DOCKER_ORG}/${PACKAGE_NAME}:${VERSION} | ||
create-manifest: | ||
docker: | ||
- image: cimg/base:current | ||
resource_class: small | ||
steps: | ||
- checkout | ||
- setup_remote_docker | ||
- configure-ghcr | ||
- tag-generator | ||
- run: | ||
name: Create and push manifest for multiarch | ||
command: | | ||
echo "Creating manifest for image: ${DOCKER_REGISTRY}/${DOCKER_ORG}/${PACKAGE_NAME}:${IMAGE_TAG}" | ||
docker manifest create \ | ||
${DOCKER_REGISTRY}/${DOCKER_ORG}/${PACKAGE_NAME}:${IMAGE_TAG} \ | ||
--amend ${DOCKER_REGISTRY}/${DOCKER_ORG}/${PACKAGE_NAME}:${IMAGE_TAG}-amd64 \ | ||
--amend ${DOCKER_REGISTRY}/${DOCKER_ORG}/${PACKAGE_NAME}:${IMAGE_TAG}-arm64 | ||
docker manifest push ${DOCKER_REGISTRY}/${DOCKER_ORG}/${PACKAGE_NAME}:${IMAGE_TAG} | ||
workflows: | ||
build-publish: | ||
jobs: | ||
- build-push-light: | ||
matrix: | ||
parameters: | ||
platform: [ amd64, arm64 ] | ||
filters: | ||
branches: | ||
only: main | ||
tags: | ||
only: /.*/ | ||
- create-manifest: | ||
requires: | ||
- build-push-light | ||
filters: | ||
branches: | ||
only: main | ||
tags: | ||
only: /.*/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.