Skip to content

Commit

Permalink
CR-846 (#3)
Browse files Browse the repository at this point in the history
* Update goreleaser.yaml
* build the binary inside Dockerfile
* pipeline changes CR-847
  • Loading branch information
alex-codefresh authored Dec 10, 2020
1 parent 96a0126 commit 5d89e47
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 55 deletions.
14 changes: 13 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
FROM golang:1.11.11-alpine3.8 as build

WORKDIR /pikolo

RUN apk add git gcc g++

COPY go.mod .
RUN go mod download

COPY . .
RUN env CGO_ENABLED=0 go build -ldflags="-s -w"

FROM alpine:3.8

RUN apk add --update ca-certificates

COPY dist/pikolo_linux_386/pikolo /usr/local/bin/
COPY --from=build /pikolo/pikolo /usr/local/bin
COPY VERSION /VERSION

LABEL io.codefresh.engine="true"
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.13.1
0.13.2
52 changes: 52 additions & 0 deletions codefresh-arm64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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
disable_push: true
dockerfile: ./Dockerfile
image_name: ${{IMAGE_NAME}}
tag: ${{CF_BRANCH_TAG_NORMALIZED}}

push_dev:
title: "Pushing image to registry with branch name"
type: push
candidate: ${{build_image}}
tag: ${{CF_BRANCH_TAG_NORMALIZED}}${{ARM_TAG_POSTFIX}}
when:
branch:
ignore: [ master ]
scale:
push_quay_dev:
registry: "${{REGISTRY_INTEGRATION_QUAY}}"
push_dockerhub_dev:
registry: "${{REGISTRY_INTEGRATION_DOCKERHUB}}"
push_gcr_enterprise_dev:
registry: "${{REGISTRY_INTEGRATION_ENTERPRISE}}"

push_master:
title: "Pushing image production tags"
type: push
candidate: ${{build_image}}
when:
branch:
only: [ master ]
tags:
- "${{CF_BRANCH_TAG_NORMALIZED}}${{ARM_TAG_POSTFIX}}"
- "${{VERSION}}${{ARM_TAG_POSTFIX}}"
- "latest${{ARM_TAG_POSTFIX}}"
scale:
push_quay_prod:
registry: "${{REGISTRY_INTEGRATION_QUAY}}"
push_dockerhub_prod:
registry: "${{REGISTRY_INTEGRATION_DOCKERHUB}}"
push_gcr_enterprise_prod:
registry: "${{REGISTRY_INTEGRATION_ENTERPRISE}}"
188 changes: 136 additions & 52 deletions codefresh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ mode: parallel

stages:
- Build & Test
- Push & Release
- Push
- Github Release

steps:
main_clone:
stage: Build & Test
type: git-clone
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
git: cf_github
git: ${{GIT_CONTEXT}}
revision: ${{CF_REVISION}}

calculate_version:
stage: Build & Test
title: 'Calculate latest version'
Expand All @@ -36,11 +37,137 @@ steps:
- name: main_clone
on:
- success


build:
title: "Building image"
type: build
stage: Build & Test
disable_push: true
tag: ${{CF_BRANCH_TAG_NORMALIZED}}
image_name: ${{IMAGE_NAME}}
when:
steps:
- name: main_clone
on:
- success

run_arm_build:
type: codefresh-run
stage: Build & Test
when:
steps:
- name: calculate_version
on:
- success
arguments:
PIPELINE_ID: ${{ARM_PIPELINE_ID}}
DETACH: false
VARIABLE:
- CF_REPO_OWNER=${{CF_REPO_OWNER}}
- CF_REPO_NAME=${{CF_REPO_NAME}}
- CF_REVISION=${{CF_REVISION}}
- CF_BRANCH=${{CF_BRANCH}}
- CF_BRANCH_TAG_NORMALIZED=${{CF_BRANCH_TAG_NORMALIZED}}
- GIT_CONTEXT=${{GIT_CONTEXT}}
- IMAGE_NAME=${{IMAGE_NAME}}
- VERSION=${{VERSION}}
- ARM_TAG_POSTFIX="${{ARM_TAG_POSTFIX}}"

push_dev_image:
title: "Pushing dev version of the image"
type: push
stage: Push
candidate: ${{build}}
tag: ${{CF_BRANCH_TAG_NORMALIZED}}
when:
steps:
- name: build
on:
- success
scale:
push_quay_dev:
registry: "${{REGISTRY_INTEGRATION_QUAY}}"
push_dockerhub_dev:
registry: "${{REGISTRY_INTEGRATION_DOCKERHUB}}"
push_gcr_enterprise_dev:
registry: "${{REGISTRY_INTEGRATION_ENTERPRISE}}"

push_prod_image:
title: "Pushing prod version of the image"
type: push
stage: Push
candidate: ${{build}}
tags:
- ${{VERSION}}
- 'latest'
when:
steps:
- name: build
on:
- success
branch:
only: [ master ]
scale:
push_quay_prod:
registry: "${{REGISTRY_INTEGRATION_QUAY}}"
push_dockerhub_prod:
registry: "${{REGISTRY_INTEGRATION_DOCKERHUB}}"
push_gcr_enterprise_prod:
registry: "${{REGISTRY_INTEGRATION_ENTERPRISE}}"

create_manifest_list:
stage: Push
type: "codefresh-inc/multiarch-manifester"
when:
steps:
- name: run_arm_build
on:
- success
arguments:
image_name: ${{IMAGE_NAME}}
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-enterprise
username: '${{GCR_USERNAME}}'
password: '${{GCR_PASSWORD}}'
scale:
master_branch_tags:
when:
branch:
only: [ master ]
steps:
- name: push_prod_image
on:
- success
arguments:
tags:
- ${{CF_BRANCH_TAG_NORMALIZED}}
- ${{VERSION}}
- latest
dev_branches_tags:
when:
branch:
ignore: [ master ]
steps:
- name: push_dev_image
on:
- success
arguments:
tags:
- ${{CF_BRANCH_TAG_NORMALIZED}}

create_git_tag:
title: Push tag to git
image: codefreshio/ci-helpers
stage: Push & Release
stage: Github Release
commands:
- source /get-token/get-gh-token.sh
- cf_export GITHUB_TOKEN
Expand All @@ -51,7 +178,7 @@ steps:
- git push --tags
- git remote rm origin
- git remote add origin $OLD_ORIGIN

fail_fast: false
when:
steps:
Expand All @@ -61,11 +188,11 @@ steps:
branch:
only:
- master

release_binaries:
title: Create release in Github
image: goreleaser/goreleaser
stage: Push & Release
stage: Github Release
fail_fast: false
commands:
- go mod download
Expand All @@ -77,47 +204,4 @@ steps:
- finished
branch:
only:
- master


build:
title: "Building production image"
type: build
stage: Build & Test
tag: ${{VERSION}}
image_name: codefresh/pikolo
when:
steps:
- name: release_binaries
on:
- success

push_cli_image_quay:
title: "Push image to Quay"
stage: Push & Release
type: push
candidate: ${{build}}
tags:
- latest
- ${{VERSION}}
registry: ${{REGISTRY_INTEGRATION_QUAY}}
when:
steps:
- name: build
on:
- success

push_cli_image_dockerub:
title: "Push image to Dockerhub"
stage: Push & Release
type: push
candidate: ${{build}}
tags:
- latest
- ${{VERSION}}
registry: "dockerhub"
when:
steps:
- name: build
on:
- success
- master
6 changes: 5 additions & 1 deletion goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ builds:
- darwin
- linux
- windows
goarch:
- 386
- amd64
- arm64
archives:
- replacements:
darwin: Darwin
Expand All @@ -24,4 +28,4 @@ changelog:
filters:
exclude:
- '^docs:'
- '^test:'
- '^test:'

0 comments on commit 5d89e47

Please sign in to comment.