diff --git a/build/build_image.sh b/build/build_image.sh new file mode 100755 index 0000000000..4ec2877985 --- /dev/null +++ b/build/build_image.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Copyright (C) 2019-2021 Zilliz. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under the License. + +set -e +set -x + +# Absolute path to the toplevel milvus directory. +toplevel=$(dirname "$(cd "$(dirname "${0}")"; pwd)") + +MILVUS_IMAGE_REPO="${MILVUS_IMAGE_REPO:-milvusdb/milvus}" +MILVUS_IMAGE_TAG="${MILVUS_IMAGE_TAG:-latest}" + +pushd "${toplevel}" + +docker build -f "./build/docker/milvus/Dockerfile" -t "${MILVUS_IMAGE_REPO}:${MILVUS_IMAGE_TAG}" . + +popd diff --git a/build/builder.sh b/build/builder.sh index 1524b7db59..8f6051f76e 100755 --- a/build/builder.sh +++ b/build/builder.sh @@ -2,7 +2,7 @@ set -euo pipefail -# Absolute path to the toplevel milvus distributed directory. +# Absolute path to the toplevel milvus directory. toplevel=$(dirname "$(cd "$(dirname "${0}")"; pwd)") pushd "${toplevel}" diff --git a/build/ci/jenkins/PublishImages.groovy b/build/ci/jenkins/PublishImages.groovy new file mode 100644 index 0000000000..e030b4fb3c --- /dev/null +++ b/build/ci/jenkins/PublishImages.groovy @@ -0,0 +1,55 @@ +#!/usr/bin/env groovy + +pipeline { + agent { + kubernetes { + label "milvus-e2e-test-kind" + defaultContainer 'main' + yamlFile "build/ci/jenkins/pod/krte.yaml" + customWorkspace '/home/jenkins/agent/workspace' + // We allow this pod to remain active for a while, later jobs can + // reuse cache in previous created nodes. + idleMinutes 120 + } + } + + options { + timestamps() + timeout(time: 30, unit: 'MINUTES') + // parallelsAlwaysFailFast() + } + + environment { + DOCKER_CREDENTIALS_ID = "ba070c98-c8cc-4f7c-b657-897715f359fc" + DOKCER_REGISTRY_URL = "registry.zilliz.com" + TARGET_REPO = "${DOKCER_REGISTRY_URL}/milvus" + } + + stages { + stage ('Publish Milvus Images') { + steps { + container('main') { + script { + sh "build/builder.sh /bin/bash -c \"make install\"" + + def date = sh(returnStdout: true, script: 'date +%Y%m%d').trim() + def gitShortCommit = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim() + + withCredentials([usernamePassword(credentialsId: "${env.DOCKER_CREDENTIALS_ID}", usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) { + sh """ + docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD} ${DOKCER_REGISTRY_URL} + export MILVUS_IMAGE_REPO="${env.TARGET_REPO}/milvus" + export MILVUS_IMAGE_TAG="${env.BRANCH_NAME}-${date}-${gitShortCommit}" + build/build_image.sh + docker push \${MILVUS_IMAGE_REPO}:\${MILVUS_IMAGE_TAG} + docker tag \${MILVUS_IMAGE_REPO}:\${MILVUS_IMAGE_TAG} \${MILVUS_IMAGE_REPO}:${env.BRANCH_NAME}-latest + docker push \${MILVUS_IMAGE_REPO}:${env.BRANCH_NAME}-latest + docker logout ${DOKCER_REGISTRY_URL} + """ + } + } + } + } + } + } +} diff --git a/tests/scripts/e2e-k8s.sh b/tests/scripts/e2e-k8s.sh index 25e4c6b682..bf59c9024d 100755 --- a/tests/scripts/e2e-k8s.sh +++ b/tests/scripts/e2e-k8s.sh @@ -273,7 +273,7 @@ if [[ -z "${SKIP_BUILD:-}" ]]; then trace "setup kind registry" setup_kind_registry pushd "${ROOT}" trace "build milvus" "${ROOT}/build/builder.sh" /bin/bash -c "${BUILD_COMMAND}" - trace "build milvus image" docker build -f "${ROOT}/build/docker/milvus/Dockerfile" -t "${MILVUS_IMAGE_REPO}:${MILVUS_IMAGE_TAG}" . + trace "build milvus image" "${ROOT}/build/build_image.sh" trace "push milvus image" docker push "${MILVUS_IMAGE_REPO}:${MILVUS_IMAGE_TAG}" popd fi