Skip to content

Commit 3cc7cb1

Browse files
Cr 2182 (#213)
* Build venonactl and venona binaries inside Dockerfiles * Combine ci and release pipelines into one; * Remove hardcoded github repo reference from .goreleaser.yml; * Add a pipeline to build an ARM image;
1 parent 7f95809 commit 3cc7cb1

File tree

10 files changed

+300
-219
lines changed

10 files changed

+300
-219
lines changed

venona/Dockerfile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
FROM golang:1.14.4-alpine3.12 as build
2+
3+
RUN apk -U add git make
4+
5+
WORKDIR /venona
6+
7+
COPY go.mod .
8+
RUN go mod download
9+
10+
COPY . .
11+
12+
RUN make build
13+
114
FROM alpine:3.12
215

316
RUN apk update && apk add --no-cache ca-certificates && apk upgrade
417

5-
COPY venona /usr/local/bin/venona
18+
COPY --from=build /venona/venona /usr/local/bin/venona
619

720
ENTRYPOINT [ "venona" ]
821

venona/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.10
1+
1.5.11

venona/build/arm-build.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
version: "1.0"
2+
3+
steps:
4+
main_clone:
5+
title: 'Cloning main repository...'
6+
type: git-clone
7+
repo: https://github.com/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
8+
revision: ${{CF_BRANCH}}
9+
git: "${{GIT_CONTEXT}}"
10+
11+
build_image:
12+
title: "Building the image..."
13+
type: build
14+
disable_push: true
15+
working_directory: ${{WORKDIR}}
16+
dockerfile: ./Dockerfile
17+
image_name: ${{IMAGE_NAME}}
18+
tag: ${{CF_BRANCH_TAG_NORMALIZED}}
19+
20+
push_dev_venona:
21+
title: "Pushing image to registry wit dev tags"
22+
type: push
23+
candidate: ${{build_image}}
24+
when:
25+
branch:
26+
ignore: [ "${{RELEASE_BRANCH_NAME}}" ]
27+
tags:
28+
- ${{VERSION}}-${{CF_BRANCH_TAG_NORMALIZED}}${{ARM_TAG_POSTFIX}}
29+
- ${{VERSION}}-${{CF_REVISION}}${{ARM_TAG_POSTFIX}}
30+
- ${{CF_REVISION}}${{ARM_TAG_POSTFIX}}
31+
- ${{CF_BRANCH_TAG_NORMALIZED}}${{ARM_TAG_POSTFIX}}
32+
scale:
33+
push_quay_dev:
34+
registry: "${{REGISTRY_INTEGRATION_QUAY}}"
35+
push_dockerhub_dev:
36+
registry: "${{REGISTRY_INTEGRATION_DOCKERHUB}}"
37+
push_gcr_enterprise_dev:
38+
registry: "${{REGISTRY_INTEGRATION_ENTERPRISE}}"
39+
40+
push_prod:
41+
title: "Pushing image to registry with prod tags"
42+
type: push
43+
candidate: ${{build_image}}
44+
when:
45+
branch:
46+
only: [ "${{RELEASE_BRANCH_NAME}}" ]
47+
tags:
48+
- ${{VERSION}}${{ARM_TAG_POSTFIX}}
49+
- ${{VERSION}}-${{CF_BRANCH_TAG_NORMALIZED}}${{ARM_TAG_POSTFIX}}
50+
- ${{VERSION}}-${{CF_REVISION}}${{ARM_TAG_POSTFIX}}
51+
- ${{CF_REVISION}}${{ARM_TAG_POSTFIX}}
52+
- ${{CF_BRANCH_TAG_NORMALIZED}}${{ARM_TAG_POSTFIX}}
53+
scale:
54+
push_quay_prod:
55+
registry: "${{REGISTRY_INTEGRATION_QUAY}}"
56+
push_dockerhub_prod:
57+
registry: "${{REGISTRY_INTEGRATION_DOCKERHUB}}"
58+
push_gcr_enterprise_prod:
59+
registry: "${{REGISTRY_INTEGRATION_ENTERPRISE}}"

venona/build/ci.yaml

Lines changed: 119 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ steps:
1111
stage: Test
1212
title: Clone repository
1313
type: git-clone
14-
repo: https://github.com/codefresh-io/venona
14+
repo: https://github.com/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
1515
revision: ${{CF_BRANCH}}
1616
credentials:
1717
username: github
@@ -116,37 +116,45 @@ steps:
116116
on:
117117
- success
118118

119-
compile:
120-
<<: *common
121-
title: Compile
122-
stage: Build Artifacts
123-
# YAML arrays cannot be merged and flatten
124-
# https://github.com/yaml/yaml/issues/35
125-
# copy the variables from the download_dependencies step
126-
environment:
127-
- GO111MODULE=on
128-
- GOSUMDB=off
129-
- GOPROXY=direct
130-
- GOCACHE=/codefresh/volume/gocache
131-
- GOPATH=/codefresh/volume/gopath
132-
- GOOS=linux
133-
- GOARCH=386
134-
commands:
135-
- cd venona && make build
136-
137119
build_image:
138120
type: build
139121
title: Build Docker Image
140122
stage: Build Artifacts
141123
tag: ${{CF_BRANCH_TAG_NORMALIZED}}
142124
dockerfile: Dockerfile
143-
working_directory: ${{main_clone}}/venona
125+
disable_push: true
126+
working_directory: ${{WORKDIR}}
144127
image_name: ${{IMAGE_NAME}}
145128
when:
146129
steps:
147-
- name: compile
130+
- name: main_clone
131+
on:
132+
- success
133+
134+
run_arm_build:
135+
type: codefresh-run
136+
stage: Build Artifacts
137+
when:
138+
steps:
139+
- name: export_version
148140
on:
149141
- success
142+
arguments:
143+
PIPELINE_ID: ${{ARM_PIPELINE_ID}}
144+
DETACH: false
145+
TRIGGER_ID: venona-arm
146+
BRANCH: "${{CF_BRANCH}}"
147+
VARIABLE:
148+
- CF_REPO_OWNER=${{CF_REPO_OWNER}}
149+
- CF_REPO_NAME=${{CF_REPO_NAME}}
150+
- CF_REVISION=${{CF_REVISION}}
151+
- CF_BRANCH=${{CF_BRANCH}}
152+
- CF_BRANCH_TAG_NORMALIZED=${{CF_BRANCH_TAG_NORMALIZED}}
153+
- IMAGE_NAME=${{IMAGE_NAME}}
154+
- WORKDIR=${{WORKDIR}}
155+
- VERSION=${{VERSION}}
156+
- RELEASE_BRANCH_NAME=${{RELEASE_BRANCH_NAME}}
157+
- ARM_TAG_POSTFIX="${{ARM_TAG_POSTFIX}}"
150158

151159
security_scan:
152160
stage: Security scan
@@ -209,24 +217,110 @@ steps:
209217
${{SEC_SCAN_REPORT_FILE}} \
210218
s3://${{SEC_SCAN_S3_BUCKET}}/${{IMAGE_NAME}}/${{CF_REPO_NAME}}:${{VERSION}}.txt
211219
212-
push:
220+
push_dev_image:
221+
type: push
222+
title: Push candidate image with dev tags
223+
stage: Push
224+
candidate: ${{build_image}}
225+
tags:
226+
- ${{VERSION}}-${{CF_BRANCH_TAG_NORMALIZED}}
227+
- ${{VERSION}}-${{CF_REVISION}}
228+
- ${{CF_REVISION}}
229+
- ${{CF_BRANCH_TAG_NORMALIZED}}
230+
image_name: ${{IMAGE_NAME}}
231+
when:
232+
branch:
233+
ignore: [ "${{RELEASE_BRANCH_NAME}}" ]
234+
steps:
235+
- name: build_image
236+
on:
237+
- success
238+
- name: export_version
239+
on:
240+
- success
241+
scale:
242+
push_quay_dev:
243+
registry: "${{REGISTRY_INTEGRATION_QUAY}}"
244+
push_dockerhub_dev:
245+
registry: "${{REGISTRY_INTEGRATION_DOCKERHUB}}"
246+
push_gcr_enterprise_dev:
247+
registry: "${{REGISTRY_INTEGRATION_ENTERPRISE}}"
248+
249+
push_prod_image:
213250
type: push
214-
title: Push candidate
251+
title: Push candidate image with prod tags
215252
stage: Push
216253
candidate: ${{build_image}}
217254
tags:
255+
- ${{VERSION}}
218256
- ${{VERSION}}-${{CF_BRANCH_TAG_NORMALIZED}}
219257
- ${{VERSION}}-${{CF_REVISION}}
220258
- ${{CF_REVISION}}
221259
- ${{CF_BRANCH_TAG_NORMALIZED}}
222-
image_name: codefresh/venona
223-
registry: dockerhub
260+
image_name: ${{IMAGE_NAME}}
224261
when:
262+
branch:
263+
only: [ "${{RELEASE_BRANCH_NAME}}" ]
225264
steps:
226265
- name: build_image
227266
on:
228267
- success
229268
- name: export_version
230269
on:
231270
- success
271+
scale:
272+
push_quay_prod:
273+
registry: "${{REGISTRY_INTEGRATION_QUAY}}"
274+
push_dockerhub_prod:
275+
registry: "${{REGISTRY_INTEGRATION_DOCKERHUB}}"
276+
push_gcr_enterprise_prod:
277+
registry: "${{REGISTRY_INTEGRATION_ENTERPRISE}}"
232278

279+
create_manifest_list:
280+
stage: Push
281+
type: "codefresh-inc/multiarch-manifester"
282+
when:
283+
steps:
284+
- name: run_arm_build
285+
on:
286+
- success
287+
arguments:
288+
image_name: ${{IMAGE_NAME}}
289+
tags:
290+
- ${{VERSION}}-${{CF_BRANCH_TAG_NORMALIZED}}
291+
- ${{VERSION}}-${{CF_REVISION}}
292+
- ${{CF_REVISION}}
293+
- ${{CF_BRANCH_TAG_NORMALIZED}}
294+
arch_tag_postfixes:
295+
arm64: "${{ARM_TAG_POSTFIX}}"
296+
registries:
297+
- name: 'quay.io'
298+
username: '${{QUAY_USERNAME}}'
299+
password: '${{QUAY_PASSWORD}}'
300+
- name: 'docker.io'
301+
username: '${{DOCKERHUB_USERNAME}}'
302+
password: '${{DOCKERHUB_PASSWORD}}'
303+
- name: 'gcr.io'
304+
path_prefix: codefresh-enterprise
305+
username: '${{GCR_USERNAME}}'
306+
password: '${{GCR_PASSWORD}}'
307+
scale:
308+
master_branch_tags:
309+
when:
310+
branch:
311+
only: [ "${{RELEASE_BRANCH_NAME}}" ]
312+
steps:
313+
- name: push_prod_image
314+
on:
315+
- success
316+
arguments:
317+
tags:
318+
- ${{VERSION}}
319+
dev_branches_tags:
320+
when:
321+
branch:
322+
ignore: [ "${{RELEASE_BRANCH_NAME}}" ]
323+
steps:
324+
- name: push_dev_image
325+
on:
326+
- success

venona/build/release.yaml

Lines changed: 0 additions & 64 deletions
This file was deleted.

venonactl/.goreleaser.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ changelog:
3737

3838

3939
release:
40-
github:
41-
owner: codefresh-io
42-
name: venona
43-
4440
# If set to auto, will mark the release as not ready for production
4541
# in case there is an indicator for this in the tag e.g. v1.0.0-rc1
4642
# If set to true, will mark the release as not ready for production.

venonactl/Dockerfile

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1-
FROM alpine:3.8
1+
FROM golang:1.14.4-alpine3.12 as build
2+
3+
WORKDIR /venona
4+
5+
COPY go.mod .
6+
RUN go mod download
7+
8+
RUN apk add git
9+
10+
COPY . .
11+
12+
ARG COMMIT
13+
14+
RUN VERSION=$(cat VERSION) \
15+
DATE=$(date -u "+%Y-%m-%dT%TZ") && \
16+
env CGO_ENABLED=0 \
17+
go build -ldflags="-w -X github.com/codefresh-io/venona/venonactl/cmd.version=${VERSION} \
18+
-X github.com/codefresh-io/venona/venonactl/cmd.commit=${COMMIT} -X github.com/codefresh-io/venona/venonactl/cmd.date=${DATE}" \
19+
-o venona
20+
21+
FROM alpine:3.12
222

323
RUN apk add --update ca-certificates
424

5-
COPY dist/venona_linux_386/venona /
25+
COPY --from=build /venona/venona /usr/local/bin/venona
626

7-
ENTRYPOINT [ "/venona" ]
27+
ENTRYPOINT [ "venona" ]
828

929
CMD [ "--help" ]

venonactl/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.10
1+
1.5.11

0 commit comments

Comments
 (0)