Skip to content

Commit 10b2796

Browse files
Merge pull request #12 from codefresh-io/SAAS-5071
Update codefresh.yml Add DOCKER_VERSION build argument Add service.yaml
2 parents 483bd45 + 50a2b99 commit 10b2796

File tree

3 files changed

+101
-9
lines changed

3 files changed

+101
-9
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
ARG DOCKER_VERSION=18.09.5
2+
13
FROM quay.io/prometheus/node-exporter:v0.15.1 AS node-exporter
24
# install node-exporter
35

46
FROM codefresh/dind-cleaner:v1.1 AS dind-cleaner
57

68
FROM codefresh/bolter AS bolter
79

8-
FROM docker:18.09.5-dind
10+
FROM docker:${DOCKER_VERSION}-dind
911
RUN apk add bash jq --no-cache
1012
COPY --from=node-exporter /bin/node_exporter /bin/
1113
COPY --from=dind-cleaner /usr/local/bin/dind-cleaner /bin/

codefresh.yml

Lines changed: 97 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,100 @@
1-
version: '1.0'
2-
1+
version: "1.0"
2+
stages:
3+
- clone
4+
- prepare
5+
- build
6+
- release
37
steps:
4-
build-step:
8+
9+
main_clone:
10+
title: 'Cloning main repository...'
11+
stage: clone
12+
type: git-clone
13+
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
14+
revision: ${{CF_BRANCH}}
15+
git: ${{GIT_CONTEXT}}
16+
17+
prepare_env_vars:
18+
title: 'Preparing environment variables...'
19+
stage: prepare
20+
image: codefreshio/ci-helpers
21+
working_directory: ${{main_clone}}
22+
commands:
23+
- cf_export DOCKER_VERSION=18.09.5
24+
- cf_export SERVICE_VERSION=$(yq r service.yaml version)
25+
- cf_export IMAGE_NAME=codefresh/dind
26+
27+
validate_version:
28+
title: 'Validating the service version...'
29+
stage: prepare
30+
image: codefreshio/ci-helpers
31+
fail_fast: false
32+
commands:
33+
- |
34+
err() { echo -e "\e[31m$@\e[0m" ; return 1 ; }
35+
ok() { echo -e "\e[32m$@\e[0m" ; return 0 ; }
36+
37+
current_version=${SERVICE_VERSION}
38+
last_version=$(git describe --abbrev=0 --tags)
39+
echo "Current version is $current_version, last version - $last_version"
40+
semver-cli greater $current_version $last_version && ok "Version check ok" || err "Please the update the version in the service.yaml file"
41+
42+
build_image:
43+
title: "Building the image..."
44+
stage: build
545
type: build
6-
image-name: codefresh/dind
46+
working_directory: ${{main_clone}}
47+
build_arguments:
48+
- DOCKER_VERSION=${{DOCKER_VERSION}}
49+
dockerfile: ./Dockerfile
50+
image_name: ${{IMAGE_NAME}}
51+
tag: ${{CF_BRANCH_TAG_NORMALIZED}}
52+
53+
approve_existing_version_update:
54+
type: pending-approval
55+
stage: release
56+
title: "Are you sure you want to update already existing image version?"
57+
description: |
58+
"Used for reverting changes without raising the service version"
59+
when:
60+
branch:
61+
only: [master]
62+
steps:
63+
- name: validate_version
64+
on:
65+
- failure
66+
67+
release:
68+
type: parallel
69+
stage: release
70+
steps:
771

8-
push to registry:
9-
type: push
10-
candidate: ${{build-step}}
11-
tag: ${{CF_BRANCH}}
72+
add_git_tag:
73+
title: "Adding Git tag..."
74+
stage: release
75+
image: codefreshio/ci-helpers
76+
commands:
77+
- source /get-token/get-gh-token.sh
78+
- |
79+
curl --fail -X POST -d '{"ref": "refs/tags/${{SERVICE_VERSION}}","sha": "${{CF_REVISION}}"}' -H "Content-Type: application/json" -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/git/refs
80+
when:
81+
branch:
82+
only: [master]
83+
steps:
84+
- name: validate_version
85+
on:
86+
- success
87+
88+
push_image_prod:
89+
type: push
90+
title: "Pushing the image to the public registry..."
91+
stage: release
92+
image_name: '${{IMAGE_NAME}}'
93+
registry: "${{REGISTRY_INTEGRATION}}"
94+
candidate: "${{build_image}}"
95+
tags:
96+
- "${{DOCKER_VERSION}}-v${{SERVICE_VERSION}}"
97+
- "latest"
98+
when:
99+
branch:
100+
only: [master]

service.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version: 1.24.1

0 commit comments

Comments
 (0)