Skip to content

Commit

Permalink
Merge pull request #147 from DARPA-ASKEM/146-add-circleci-support
Browse files Browse the repository at this point in the history
add circleci support
  • Loading branch information
YohannParis authored Aug 2, 2024
2 parents 653942a + 9a1e1c0 commit e54b1bb
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 87 deletions.
132 changes: 132 additions & 0 deletions .circleci/config.yml
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: /.*/
54 changes: 0 additions & 54 deletions .github/workflows/publish-cloud-builder.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/publish.yaml

This file was deleted.

0 comments on commit e54b1bb

Please sign in to comment.