Skip to content

Commit

Permalink
[CI] duplicate releases to docker hub
Browse files Browse the repository at this point in the history
Successful releases are mirrored to hub.docker.com
  • Loading branch information
nvjmayo committed Sep 22, 2020
1 parent 2c19a67 commit 49427e7
Showing 1 changed file with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions .nvidia-ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
---
##
## Variables that control where build artifacts are places for scanning and testing:
## Variables that control the CI artifacts (private registry, for scanning and testing):
## CI_REGISTRY
## CI_REGISTRY_IMAGE
## CI_REGISTRY_USER
## CI_REGISTRY_PASSWORD
##
## Variables that control where release artifacts go:
## RELEASE_REGISTRY
## RELEASE_REGISTRY_IMAGE
## RELEASE_REGISTRY_USER
## RELEASE_REGISTRY_PASSWORD
## Variables that control where NGC release artifacts go:
## NGC_REGISTRY
## NGC_REGISTRY_IMAGE
## NGC_REGISTRY_USER
## NGC_REGISTRY_TOKEN
##
## Variables that control where Docker Hub release artifacts go:
## REGISTRY_TOKEN
## REGISTRY_USER
## DOCKERHUB_REGISTRY_IMAGE
##

default:
Expand All @@ -34,6 +39,7 @@ stages:
- scan
- deploy
- release
- release_dockerhub

.builddep_setup: &builddep_setup
- apk add --no-cache bash findutils libmagic curl make git
Expand All @@ -56,8 +62,11 @@ stages:
- docker tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA}-centos7 ${CI_PROJECT_NAME}:${CI_COMMIT_SHA}-centos7
- docker tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA}-ubi8 ${CI_PROJECT_NAME}:${CI_COMMIT_SHA}-ubi8

.releasedockerlogin_setup: &releasedockerlogin_setup
- 'docker login -u "${RELEASE_REGISTRY_USER}" -p "${RELEASE_REGISTRY_PASSWORD}" "${RELEASE_REGISTRY}"'
.ngc_release_login: &ngc_release_login
- 'docker login -u "${NGC_REGISTRY_USER}" -p "${NGC_REGISTRY_TOKEN}" "${NGC_REGISTRY}"'

.dockerhub_login: &dockerhub_login
- 'docker login -u "${REGISTRY_USER}" -p "${REGISTRY_TOKEN}"'

.build_action: &build_action
- make IMAGE="${CI_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_SHA}" all
Expand All @@ -80,10 +89,16 @@ stages:
- python3 contamer.py -ls --fail-on-non-os --suppress-vulns CVE-2020-14352 CVE-2020-15888 -- ${CI_PROJECT_NAME}:${CI_COMMIT_SHA}-ubi8

.release_action: &release_action
- make IMAGE="${RELEASE_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_TAG}" all
- make IMAGE="${RELEASE_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_TAG}" push
- make IMAGE="${RELEASE_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_TAG}" push-short
- make IMAGE="${RELEASE_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_TAG}" push-latest
- make IMAGE="${NGC_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_TAG}" all
- make IMAGE="${NGC_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_TAG}" push
- make IMAGE="${NGC_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_TAG}" push-short
- make IMAGE="${NGC_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_TAG}" push-latest

.dockerhub_release_action: &dockerhub_release_action
- make IMAGE="${DOCKERHUB_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_TAG}" all
- make IMAGE="${DOCKERHUB_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_TAG}" push
- make IMAGE="${DOCKERHUB_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_TAG}" push-short
- make IMAGE="${DOCKERHUB_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_TAG}" push-latest

build:
stage: build
Expand Down Expand Up @@ -122,5 +137,14 @@ release:
script:
- 'echo Commit Tag: $CI_COMMIT_TAG ; [[ -n "$CI_COMMIT_TAG" ]] || exit 1'
- *builddep_setup
- *releasedockerlogin_setup
- *ngc_release_login
- *release_action

release_dockerhub:
stage: release_dockerhub
only:
- tags
script:
- *builddep_setup
- *dockerhub_login
- *dockerhub_release_action

0 comments on commit 49427e7

Please sign in to comment.