From c8bcb18200c25644f0c4d243463cb963ef4469fc Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Thu, 24 Oct 2019 09:12:46 -0700 Subject: [PATCH] Updated scripts Signed-off-by: James Ketrenos --- scripts/build-images | 10 +++++----- scripts/push-images | 42 ++++++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/scripts/build-images b/scripts/build-images index 85b527c..8a06fef 100755 --- a/scripts/build-images +++ b/scripts/build-images @@ -16,12 +16,12 @@ export $(sed -nE "s,(^[^#][^=]*).*$,\1,pg" MANIFEST | ${CMD} -d '\n') AGAMA_VERSION=${AGAMA_VERSION:-N/A} [[ "${AGAMA_VERSION}" == "N/A" ]] && { - TAG=${TAG:-build-$(date +%Y%m%d)} + TAG=${TAG:-test-build-${PACKAGE_STREAM}-$(date +%Y%m%d)} } || { - TAG=${TAG:-agama-${AGAMA_VERSION}} + TAG=${TAG:-test-agama-${AGAMA_VERSION}} } -docker build . -t ${CONTAINER}:${TAG} || { +docker build -t ${CONTAINER}:${TAG} . $* || { cat << EOM Building docker image failed. @@ -30,14 +30,14 @@ EOM exit $? } -docker tag ${CONTAINER}:agama-${AGAMA_VERSION} ${CONTAINER} +docker tag ${CONTAINER}:${TAG} ${CONTAINER} rc=$? if [ $rc -ne 0 ]; then exit 1 fi cat << EOM -This image was built and locally tagged as ${CONTAINER}:agama-${AGAMA_VERSION} +This image was built and locally tagged as ${CONTAINER}:${TAG} See 'scripts/push-images' for information on pushing this tag to Harbor. diff --git a/scripts/push-images b/scripts/push-images index d527889..8ded4df 100755 --- a/scripts/push-images +++ b/scripts/push-images @@ -14,32 +14,38 @@ fi export $(sed -nE "s,(^[^#][^=]*).*$,\1,pg" SOLUTION | ${CMD} -d '\n') export $(sed -nE "s,(^[^#][^=]*).*$,\1,pg" MANIFEST | ${CMD} -d '\n') -docker tag ${CONTAINER}:agama-${AGAMA_VERSION} ${REPO_URL}/${CONTAINER}:devel -docker push ${REPO_URL}/${CONTAINER}:devel -rc=$? -if [ $rc -ne 0 ]; then - exit 1 -fi +AGAMA_VERSION=${AGAMA_VERSION:-N/A} +[[ "${AGAMA_VERSION}" == "N/A" ]] && { + TAG=${TAG:-test-build-${PACKAGE_STREAM}-$(date +%Y%m%d)} +} || { + TAG=${TAG:-test-agama-${PACKAGE_STREAM}-${AGAMA_VERSION}} +} + +docker tag ${CONTAINER}:${TAG} ${REPO_URL}/${CONTAINER}:${TAG} \ +&& docker push ${REPO_URL}/${CONTAINER}:${TAG} \ +|| exit 1 cat << EOM -This image was pushed to the devel tag - amr-registry.caas.intel.com/vtt-osgc/solutions/${CONTAINER}:devel +This image was pushed with the 'test-' tag prefix: -If the build looks good, you should commit the changes -to Dockerfile and tag it as agama-${AGAMA_VERSION} + amr-registry.caas.intel.com/vtt-osgc/solutions/${CONTAINER}:${TAG/test-} - git commit -s -a -m "Build of agama-${AGAMA_VERSION}" - git tag -f agama-${AGAMA_VERSION} +If the build looks good, you can promote this build: -To push to the tag to Harbor: +1. Tag the tree it as ${TAG} - docker tag ${CONTAINER}:agama-${AGAMA_VERSION} amr-registry.caas.intel.com/vtt-osgc/solutions/${CONTAINER}:agama-${AGAMA_VERSION} - docker push amr-registry.caas.intel.com/vtt-osgc/solutions/${CONTAINER}:agama-${AGAMA_VERSION} + git commit -s -a -m "Build of ${TAG/test-}" + git tag -f ${TAG/test-} -If this is a good build, then roll the 'latest' tag to it. +2. Remove the 'test-' prefix from the tag: - docker tag ${CONTAINER}:agama-${AGAMA_VERSION} amr-registry.caas.intel.com/vtt-osgc/solutions/${CONTAINER}:latest - docker push amr-registry.caas.intel.com/vtt-osgc/solutions/${CONTAINER}:latest + docker tag ${CONTAINER}:${TAG/test-} amr-registry.caas.intel.com/vtt-osgc/solutions/${CONTAINER}:${TAG/test-} + docker push amr-registry.caas.intel.com/vtt-osgc/solutions/${CONTAINER}:${TAG/test-} + +3. Roll this version to the 'latest': + + docker tag ${CONTAINER}:${TAG/test-} amr-registry.caas.intel.com/vtt-osgc/solutions/${CONTAINER}:latest-${PACKAGE_STREAM} + docker push amr-registry.caas.intel.com/vtt-osgc/solutions/${CONTAINER}:latest-${PACKAGE_STREAM} EOM