Commit d3dc7402 authored by Alexx Perloff's avatar Alexx Perloff
Browse files

Try to build the image once and push to both the GitLab and DockerHub registries.

parent 85fbd6fc
Pipeline #2630036 failed with stage
in 1 minute and 42 seconds
......@@ -11,7 +11,6 @@ before_script:
stage: build
variables:
NO_CACHE: "true"
REPO_NAME: treemaker
CONTEXT_DIR: "standalone/"
IMAGE_NAME: cmssw
tags:
......@@ -23,12 +22,15 @@ before_script:
# Build and push the image from the Dockerfile at the root of the project.
# To push to a specific docker tag, amend the --destination parameter, e.g. --destination $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
# See https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#variables-reference for available variables
- echo "Pipeline source - $CI_PIPELINE_SOURCE"
- echo "Base image - $BASE_IMAGE"
- echo "Building standalone image ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${CMSSW_VERSION}-${DATE}-${CI_COMMIT_SHORT_SHA} with ${CMSSW_VERSION} and ${SCRAM_ARCH}" on ${DATE}
- echo ${CI_PROJECT_DIR}/${CONTEXT_DIR}/
- ls -alh ${CI_PROJECT_DIR}/${CONTEXT_DIR}/
- echo "Logging into the registry ${CI_REGISTRY}"
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"username\":\"${CI_REGISTRY_USER}\",\"password\":\"${CI_REGISTRY_PASSWORD}\"}}}" > /kaniko/.docker/config.json
- echo "Building standalone image ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${CMSSW_VERSION}-${DATE}-${CI_COMMIT_SHORT_SHA} with ${CMSSW_VERSION} and ${SCRAM_ARCH}" on ${DATE}
- /kaniko/executor --context ${CI_PROJECT_DIR}/${CONTEXT_DIR} --dockerfile ${CI_PROJECT_DIR}/${CONTEXT_DIR}/Dockerfile --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${CMSSW_VERSION}-${DATE}-${CI_COMMIT_SHORT_SHA}" --build-arg=BUILD_DATE="${DATE}" --build-arg=VERSION="${DATE}" --build-arg=VCS_URL="${CI_REPOSITORY_URL}" --build-arg=VCS_REF="${CI_COMMIT_SHORT_SHA}" --build-arg BASEIMAGE="${BASE_IMAGE}" --build-arg SCRAM_ARCH="${SCRAM_ARCH}" --build-arg CMSSW_VERSION="${CMSSW_VERSION}"
- export DOCKER_AUTH="$(echo -n $DOCKER_USERNAME:$DOCKER_PASSWORD | base64)" # https://github.com/GoogleContainerTools/kaniko#pushing-to-docker-hub
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"username\":\"${CI_REGISTRY_USER}\",\"password\":\"${CI_REGISTRY_PASSWORD}\"}, \"${DOCKER_REGISTRY\":{\"auth\":\"${DOCKER_AUTH}\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context ${CI_PROJECT_DIR}/${CONTEXT_DIR} --dockerfile ${CI_PROJECT_DIR}/${CONTEXT_DIR}/Dockerfile --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${CMSSW_VERSION}-${DATE}-${CI_COMMIT_SHORT_SHA}" --destination "${DOCKER_GROUP}/${IMAGE_NAME}:${CMSSW_VERSION}-${DATE}-${CI_COMMIT_SHORT_SHA}" --build-arg=BUILD_DATE="${DATE}" --build-arg=VERSION="${DATE}" --build-arg=VCS_URL="${CI_REPOSITORY_URL}" --build-arg=VCS_REF="${CI_COMMIT_SHORT_SHA}" --build-arg BASEIMAGE="${BASE_IMAGE}" --build-arg SCRAM_ARCH="${SCRAM_ARCH}" --build-arg CMSSW_VERSION="${CMSSW_VERSION}"
# Jobs/Includes ---------------------------------------------------------------
include:
......
......@@ -4,14 +4,5 @@ build_TreeMaker_cmssw_standalone_CMSSW_10_6_25:
CMSSW_VERSION: CMSSW_10_6_25
SCRAM_ARCH: slc7_amd64_gcc700
BASE_IMAGE: clelange/cc7-cms:latest
build_TreeMaker_cmssw_standalone_CMSSW_10_6_25_dockerhub:
extends: .job_template
variables:
CMSSW_VERSION: CMSSW_10_6_25
SCRAM_ARCH: slc7_amd64_gcc700
BASE_IMAGE: clelange/cc7-cms:latest
CI_REGISTRY: https://index.docker.io/v1/
CI_REGISTRY_USER: ${DOCKER_USERNAME}
CI_REGISTRY_PASSWORD: ${DOCKER_PASSWORD}
CI_REGISTRY_IMAGE: index.docker.io/${REPO_NAME}
\ No newline at end of file
DOCKER_GROUP: treemaker
DOCKER_REGISTRY: https://index.docker.io/v1/
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment