From: Lusheng Ji Date: Thu, 14 Sep 2017 00:20:34 +0000 (+0000) Subject: Use standard docker tag X-Git-Tag: v1.1.4~29 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=d5dc08c6f474414570009b6ff6041c30e4cf192f;p=dcaegen2%2Fcollectors%2Fves.git Use standard docker tag Issue-Id: DCAEGEN2-60 Change-Id: I8c2a9a9542db66b2a82ab4795b411e11691e0f13 Signed-off-by: Lusheng Ji --- diff --git a/.gitignore b/.gitignore index fa1b661a..341ce229 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .settings logs /bin/ +/opt/ diff --git a/mvn-phase-script.sh b/mvn-phase-script.sh index 9603bb4d..ea045de5 100755 --- a/mvn-phase-script.sh +++ b/mvn-phase-script.sh @@ -117,16 +117,84 @@ install) ;; deploy) echo "==> deploy phase script" - # build docker image from Docker file (under root of repo) and push to registry - #build_and_push_docker + case $MVN_DEPLOYMENT_TYPE in - SNAPSHOT) - bash docker-build.sh merge - ;; - STAGING) - bash docker-build.sh release - ;; - esac + SNAPSHOT) + phase='merge' + ;; + STAGING) + phase='release' + ;; + *) + exit 1 + ;; + esac + + VERSION=$(xpath -e '//project/version/text()' 'pom.xml') + VERSION=${VERSION//\"/} + EXT=$(echo "$VERSION" | rev | cut -s -f1 -d'-' | rev) + if [ -z "$EXT" ]; then + EXT="STAGING" + fi + case $phase in + verify|merge) + if [ "$EXT" != 'SNAPSHOT' ]; then + echo "$phase job only takes SNAPSHOT version, got \"$EXT\" instead" + exit 1 + fi + ;; + release) + if [ ! -z "$EXT" ] && [ "$EXT" != 'STAGING' ]; then + echo "$phase job only takes STAGING or pure numerical version, got \"$EXT\" instead" + exit 1 + fi + ;; + *) + echo "Unknown phase \"$phase\"" + exit 1 + esac + echo "Running \"$phase\" job for version \"$VERSION\"" + + # unarchive the service manager + TARGET="${WORKSPACE}/target" + #STAGE="${TARGET}/stage" + STAGE=. + BASE_DIR="${STAGE}/opt/app" + + # unarchive the collector + AR=${WORKSPACE}/target/VESCollector-${VERSION}-bundle.tar.gz + APP_DIR=${STAGE}/opt/app/VESCollector + + [ -d "${STAGE}/opt/app/VESCollector-${VERSION}" ] && rm -rf "${STAGE}/opt/app/VESCollector-${VERSION}" + + [ ! -f "${APP_DIR}" ] && mkdir -p "${APP_DIR}" + + gunzip -c "${AR}" | tar xvf - -C "${APP_DIR}" --strip-components=1 + + + if [ ! -f "${APP_DIR}/bin/docker-entry.sh" ] + then + echo "FATAL error cannot locate ${APP_DIR}/bin/docker-entry.sh" + exit 2 + fi + cp -p ${APP_DIR}/bin/docker-entry.sh ${BASE_DIR}/docker-entry.sh + chmod 755 "${BASE_DIR}/docker-entry.sh" + + + + + # + # generate docker file + # + if [ ! -f "${APP_DIR}/Dockerfile" ] + then + echo "FATAL error cannot locate ${APP_DIR}/Dockerfile" + exit 2 + fi + cp -p ${APP_DIR}/Dockerfile ${STAGE}/Dockerfile + + BUILD_PATH="${WORKSPACE}/target/stage" + build_and_push_docker ;; *) echo "==> unprocessed phase" diff --git a/pom.xml b/pom.xml index 5160bf85..9fd795a2 100644 --- a/pom.xml +++ b/pom.xml @@ -545,6 +545,19 @@ + + install script + install + + exec + + + + __ + install + + +