From 643bf30959ace58421f2262444722bff4d04c7ca Mon Sep 17 00:00:00 2001 From: Scott Arnette Date: Tue, 25 Feb 2020 10:21:35 -0500 Subject: [PATCH] Create base images pipeline. --- .cicd/base-images.yml | 121 ++++++++++++++++++++++++++++++++++ .cicd/generate-base-images.sh | 11 +++- 2 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 .cicd/base-images.yml diff --git a/.cicd/base-images.yml b/.cicd/base-images.yml new file mode 100644 index 000000000..045f51e16 --- /dev/null +++ b/.cicd/base-images.yml @@ -0,0 +1,121 @@ +steps: + - wait + + - label: ":aws: Amazon_Linux 2 - Base Image Pinned" + command: + - "./.cicd/generate-base-images.sh" + env: + FORCE_BASE_IMAGE: true + IMAGE_TAG: amazon_linux-2-pinned + PLATFORM_TYPE: pinned + agents: + queue: "automation-eks-eos-builder-fleet" + timeout: 180 + + - label: ":centos: CentOS 7.7 - Base Image Pinned" + command: + - "./.cicd/generate-base-images.sh" + env: + FORCE_BASE_IMAGE: true + IMAGE_TAG: centos-7.7-pinned + PLATFORM_TYPE: pinned + agents: + queue: "automation-eks-eos-builder-fleet" + timeout: 180 + + - label: ":darwin: macOS 10.14 - Base Image Pinned" + command: + - "git clone git@github.com:EOSIO/eos.git eos && cd eos && git checkout -f $BUILDKITE_BRANCH" + - "cd eos && ./.cicd/platforms/pinned/macos-10.14-pinned.sh" + plugins: + - EOSIO/anka#v0.6.0: + debug: true + vm-name: "10.14.6_6C_14G_40G" + no-volume: true + always-pull: true + wait-network: true + vm-registry-tag: "clean::cicd::git-ssh::nas::brew::buildkite-agent" + failover-registries: + - "registry_1" + - "registry_2" + inherit-environment-vars: true + - EOSIO/skip-checkout#v0.1.1: + cd: ~ + agents: "queue=mac-anka-node-fleet" + timeout: 180 + + - label: ":ubuntu: Ubuntu 16.04 - Base Image Pinned" + command: + - "./.cicd/generate-base-images.sh" + env: + FORCE_BASE_IMAGE: true + IMAGE_TAG: ubuntu-16.04-pinned + PLATFORM_TYPE: pinned + agents: + queue: "automation-eks-eos-builder-fleet" + timeout: 180 + + - label: ":ubuntu: Ubuntu 18.04 - Base Image Pinned" + command: + - "./.cicd/generate-base-images.sh" + env: + FORCE_BASE_IMAGE: true + IMAGE_TAG: ubuntu-18.04-pinned + PLATFORM_TYPE: pinned + agents: + queue: "automation-eks-eos-builder-fleet" + timeout: 180 + + - label: ":aws: Amazon_Linux 2 - Base Image Unpinned" + command: + - "./.cicd/generate-base-images.sh" + env: + FORCE_BASE_IMAGE: true + IMAGE_TAG: amazon_linux-2-unpinned + PLATFORM_TYPE: unpinned + agents: + queue: "automation-eks-eos-builder-fleet" + timeout: 180 + + - label: ":centos: CentOS 7.7 - Base Image Unpinned" + command: + - "./.cicd/generate-base-images.sh" + env: + FORCE_BASE_IMAGE: true + IMAGE_TAG: centos-7.7-unpinned + PLATFORM_TYPE: unpinned + agents: + queue: "automation-eks-eos-builder-fleet" + timeout: 180 + + - label: ":darwin: macOS 10.14 - Base Image Unpinned" + command: + - "git clone git@github.com:EOSIO/eos.git eos && cd eos && git checkout -f $BUILDKITE_BRANCH" + - "cd eos && ./.cicd/platforms/unpinned/macos-10.14-unpinned.sh" + plugins: + - EOSIO/anka#v0.6.0: + debug: true + vm-name: "10.14.6_6C_14G_40G" + no-volume: true + always-pull: true + wait-network: true + vm-registry-tag: "clean::cicd::git-ssh::nas::brew::buildkite-agent" + failover-registries: + - "registry_1" + - "registry_2" + inherit-environment-vars: true + - EOSIO/skip-checkout#v0.1.1: + cd: ~ + agents: "queue=mac-anka-node-fleet" + timeout: 180 + + - label: ":ubuntu: Ubuntu 18.04 - Base Image Unpinned" + command: + - "./.cicd/generate-base-images.sh" + env: + FORCE_BASE_IMAGE: true + IMAGE_TAG: ubuntu-18.04-unpinned + PLATFORM_TYPE: unpinned + agents: + queue: "automation-eks-eos-builder-fleet" + timeout: 180 \ No newline at end of file diff --git a/.cicd/generate-base-images.sh b/.cicd/generate-base-images.sh index d05a4a25b..d4d52233f 100755 --- a/.cicd/generate-base-images.sh +++ b/.cicd/generate-base-images.sh @@ -8,9 +8,14 @@ ORG_REPO=$(echo $FULL_TAG | cut -d: -f1) TAG=$(echo $FULL_TAG | cut -d: -f2) EXISTS=$(curl -s -H "Authorization: Bearer $(curl -sSL "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${ORG_REPO}:pull" | jq --raw-output .token)" "https://registry.hub.docker.com/v2/${ORG_REPO}/manifests/$TAG") # build, if neccessary -if [[ $EXISTS =~ '404 page not found' || $EXISTS =~ 'manifest unknown' || $FORCE_BASE_IMAGE == 'true' ]]; then # if we cannot pull the image, we build and push it first - docker build -t $FULL_TAG -f $CICD_DIR/platforms/$PLATFORM_TYPE/$IMAGE_TAG.dockerfile . - docker push $FULL_TAG +if [[ $EXISTS =~ '404 page not found' || $EXISTS =~ 'manifest unknown' || $FORCE_BASE_IMAGE == true ]]; then # if we cannot pull the image, we build and push it first + docker build --no-cache -t $FULL_TAG -f $CICD_DIR/platforms/$PLATFORM_TYPE/$IMAGE_TAG.dockerfile . + if [[ $FORCE_BASE_IMAGE != true ]]; then + docker push $FULL_TAG + else + echo "Base image creation successful. Not pushing...". + exit 0 + fi else echo "$FULL_TAG already exists." fi \ No newline at end of file