From 89b33ae39cd9c2fbb274eb3e69f3449570fd0ec6 Mon Sep 17 00:00:00 2001 From: Pavel Nosovets <56305887+palson-cf@users.noreply.github.com> Date: Tue, 15 Dec 2020 00:09:06 +0300 Subject: [PATCH] Add ARM support (#608) * Update Dockerfile * Added arm build * Fix stage * Fix pipeline run step * Added manifests to pipeline * Fix push step * Updated gcr creds * Added test step * Added test step * Removed test step * Added test step * Removed test step * Override gcr registry * Update release pipeline * Bump version * Added codefresh-arm.yml * Update pipelines * Update trigger name * Added titles --- Dockerfile | 9 +---- codefresh-arm.yml | 54 +++++++++++++++++++++++++++ codefresh-release.yml | 53 +++++++++++++++++++------- codefresh.yml | 87 ++++++++++++++++++++++++++++++++++++------- package.json | 2 +- 5 files changed, 171 insertions(+), 34 deletions(-) create mode 100644 codefresh-arm.yml diff --git a/Dockerfile b/Dockerfile index 08ef29341..82ea267cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,18 +11,13 @@ RUN pip install yq==${YQ_VERSION} RUN pyinstaller --noconfirm --onefile --log-level DEBUG --clean --distpath /tmp/ $(which yq) # Main -FROM codefresh/node:10.15.3-alpine3.11 +FROM node:10.23.0-alpine3.11 -RUN apk --update add --no-cache ca-certificates git curl bash yarn +RUN apk --update add --no-cache ca-certificates git curl bash yarn jq=1.6-r0 COPY --from=go /go/bin/hub /usr/local/bin/hub COPY --from=yq /tmp/yq /usr/local/bin/yq -ARG JQ_VERSION=1.6 - -RUN wget -O /usr/local/bin/jq https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64 && \ - chmod +x /usr/local/bin/* - WORKDIR /cf-cli COPY package.json /cf-cli diff --git a/codefresh-arm.yml b/codefresh-arm.yml new file mode 100644 index 000000000..a2b1b4581 --- /dev/null +++ b/codefresh-arm.yml @@ -0,0 +1,54 @@ +version: "1.0" +steps: + main_clone: + title: 'Cloning main repository...' + type: git-clone + repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} + revision: ${{CF_REVISION}} + git: ${{GIT_CONTEXT}} + + build_image: + title: "Building the image..." + type: build + working_directory: ${{WORKDIR}} + disable_push: true + dockerfile: ./Dockerfile + image_name: ${{IMAGE_NAME}} + tag: ${{CF_SHORT_REVISION}} + + push_dev: + type: push + candidate: ${{build_image}} + title: "Pushing image to registry with revision tag" + tag: ${{CF_SHORT_REVISION}}${{ARM_TAG_POSTFIX}} + scale: + push_quay_dev: + registry: "${{REGISTRY_INTEGRATION_QUAY}}" + title: "Pushing image to quay.io registry with revision tag" + push_dockerhub_dev: + registry: "${{REGISTRY_INTEGRATION_DOCKERHUB}}" + title: "Pushing image to dockerhub registry with revision tag" + push_gcr_enterprise_dev: + registry: "${{REGISTRY_INTEGRATION_ENTERPRISE}}" + title: "Pushing image to gcr.io registry with revision tag" + + push_master: + type: push + candidate: ${{build_image}} + title: "Pushing image with release tag" + when: + branch: + only: [ master ] + tags: + - "${{PACKAGE_VERSION}}${{ARM_TAG_POSTFIX}}" + - "latest${{ARM_TAG_POSTFIX}}" + scale: + push_quay_prod: + registry: "${{REGISTRY_INTEGRATION_QUAY}}" + title: "Pushing image to quay.io registry with release tag" + push_dockerhub_prod: + registry: "${{REGISTRY_INTEGRATION_DOCKERHUB}}" + title: "Pushing image to dockerhub registry with release tag" + push_gcr_enterprise_prod: + registry: "${{REGISTRY_INTEGRATION_ENTERPRISE}}" + title: "Pushing image to gcr.io registry with release tag" diff --git a/codefresh-release.yml b/codefresh-release.yml index 094b42c43..40d99bb4e 100644 --- a/codefresh-release.yml +++ b/codefresh-release.yml @@ -29,21 +29,48 @@ steps: - "cf_export PACKAGE_VERSION" # in case the candidate image will not be found the release flow will crash and this means that the build pipelines has failed - push_to_registry_version: - title: "Update dockerhub image version tag" + push_step: type: push - candidate: gcr.io/codefresh-inc/codefresh/cli:${{CF_SHORT_REVISION}} - image_name: codefresh/cli - tag: ${{PACKAGE_VERSION}} - registry: dockerhub + title: "Push release image" + tags: + - ${{PACKAGE_VERSION}} + - latest + scale: + push_to_dockerhub: + registry: dockerhub + title: "push to dockerhub" + candidate: codefresh/cli:${{CF_SHORT_REVISION}} + push_to_gcr: + title: "push to gcr" + candidate: gcr.io/codefresh-inc/codefresh/cli:${{CF_SHORT_REVISION}} + push_to_quay: + registry: cf-quay + title: "push to quay.io" + candidate: quay.io/codefresh/codefresh/cli:${{CF_SHORT_REVISION}} - push_to_registry_latest: - title: "Update dockerhub image latest tag" - type: push - candidate: gcr.io/codefresh-inc/codefresh/cli:${{CF_SHORT_REVISION}} - image_name: codefresh/cli - tag: latest - registry: dockerhub + create_manifest_list: + type: "codefresh-inc/multiarch-manifester" + arguments: + image_name: codefresh/cli + arch_tag_postfixes: + arm64: "${{ARM_TAG_POSTFIX}}" + registries: + - name: 'quay.io' + username: '${{QUAY_USERNAME}}' + password: '${{QUAY_PASSWORD}}' + - name: 'docker.io' + username: '${{DOCKERHUB_USERNAME}}' + password: '${{DOCKERHUB_PASSWORD}}' + - name: 'gcr.io' + path_prefix: codefresh-inc + username: '${{GCR_CODEFRESH_INC_USERNAME}}' + password: '${{GCR_CODEFRESH_INC_PASSWORD}}' + scale: + master_branch_tags: + arguments: + tags: + - ${{PACKAGE_VERSION}} + - latest generate_comletion: title: "Generating commands completion tree" diff --git a/codefresh.yml b/codefresh.yml index 13fa02510..4295ada97 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -28,11 +28,42 @@ steps: commands: - yarn test - build_step: - type: build - dockerfile: Dockerfile - image-name: codefresh/cli - tag: ${{CF_BRANCH_TAG_NORMALIZED}} + extract_version: + title: "Exporting package.json version" + image: codefresh/build-cli + commands: + - 'export PACKAGE_VERSION=$(jq -r ".version" package.json)' + - "echo Current version: $PACKAGE_VERSION" + - "cf_export PACKAGE_VERSION" + + build_images: + type: parallel + steps: + + build_step: + type: build + dockerfile: Dockerfile + image-name: codefresh/cli + tag: ${{CF_BRANCH_TAG_NORMALIZED}} + + run_arm_build: + type: codefresh-run + arguments: + PIPELINE_ID: 'codefresh-io/cli/build-arm' + TRIGGER_ID: codefresh-io/cli + BRANCH: ${{CF_BRANCH}} + DETACH: false + VARIABLE: + - CF_REPO_OWNER=${{CF_REPO_OWNER}} + - CF_REPO_NAME=${{CF_REPO_NAME}} + - CF_REVISION=${{CF_REVISION}} + - CF_BRANCH=${{CF_BRANCH}} + - CF_SHORT_REVISION=${{CF_SHORT_REVISION}} + - GIT_CONTEXT=cf_github + - IMAGE_NAME=codefresh/cli + - WORKDIR=${{CF_VOLUME_PATH}}/${{CF_REPO_NAME}} + - ARM_TAG_POSTFIX="${{ARM_TAG_POSTFIX}}" + - PACKAGE_VERSION=${{PACKAGE_VERSION}} push_step: type: push @@ -41,19 +72,49 @@ steps: scale: push_to_dockerhub: registry: dockerhub - title: "push to dockerhub" + title: "push to dockerhub" push_to_gcr: - title: "push to gcr" + title: "push to gcr" + push_to_quay: + registry: cf-quay + title: "push to quay.io" + + create_manifest_list: + type: "codefresh-inc/multiarch-manifester" + arguments: + image_name: codefresh/cli + arch_tag_postfixes: + arm64: "${{ARM_TAG_POSTFIX}}" + registries: + - name: 'quay.io' + username: '${{QUAY_USERNAME}}' + password: '${{QUAY_PASSWORD}}' + - name: 'docker.io' + username: '${{DOCKERHUB_USERNAME}}' + password: '${{DOCKERHUB_PASSWORD}}' + - name: 'gcr.io' + path_prefix: codefresh-inc + username: '${{GCR_CODEFRESH_INC_USERNAME}}' + password: '${{GCR_CODEFRESH_INC_PASSWORD}}' + scale: + dev_branches_tags: + when: + branch: + ignore: [ master ] + arguments: + tags: + - ${{CF_SHORT_REVISION}} execute_release_pipeline: title: "Execute release pipeline in case version was changed" fail_fast: false - image: codefresh/cli - commands: - - 'apk update && apk add jq' - - 'export PACKAGE_VERSION=$(jq -r ".version" package.json)' - - "echo Current version: $PACKAGE_VERSION" - - "git tag $PACKAGE_VERSION && echo Running release pipeline && codefresh run 5a4c94d282ed4d00012b54e8 -b=master --detach" + type: codefresh-run + arguments: + PIPELINE_ID: 'codefresh-io/cli/release' + DETACH: true + BRANCH: master + VARIABLE: + - PACKAGE_VERSION=${{PACKAGE_VERSION}} when: branch: only: [ master ] diff --git a/package.json b/package.json index 461919a2d..da99400b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.73.30", + "version": "0.73.31", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,