diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc4c37f18d80215642872cce13ce25bb1c76a681..0607c8ed688d388ab198fa569f62913d30f3ccee 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,15 +7,18 @@ stages: .build_image: &build_image image: - # We recommend using the CERN version of the Kaniko image: gitlab-registry.cern.ch/ci-tools/docker-image-builder - name: gitlab-registry.cern.ch/ci-tools/docker-image-builder + # The kaniko debug image is recommended because it has a shell, and a shell is required for an image to be used with GitLab CI/CD. + name: gcr.io/kaniko-project/executor:debug entrypoint: [""] script: - # This is not the common Authentication config, unknown reason why common config fails - - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64)\"}}}" > /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}:${TAG}" $BUILD_ARGS - - echo "Image pushed to ${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${TAG}" + # define script variables, they are passed in build time + - IMAGE_DESTINATION=${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${TAG} + # Prepare Kaniko configuration file + - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json + # Build and push the image from the Dockerfile at the root of the project. + - /kaniko/executor --context "$CI_PROJECT_DIR/$CONTEXT_DIR" --dockerfile "$CI_PROJECT_DIR/$CONTEXT_DIR/$DOCKERFILE" --destination "${IMAGE_DESTINATION}" $BUILD_ARGS + # Print the full registry path of the pushed image + - echo "Image pushed to ${IMAGE_DESTINATION}" environment: stage: environment