From: re2429 Date: Tue, 2 Oct 2018 14:24:09 +0000 (-0400) Subject: Let user determine how the container is built X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=d6fb4131a2af5fd93b91d5881ee43aa7c7d99b7f;p=ci-management.git Let user determine how the container is built Change-Id: I84f4e9a0830f3282c48b586cc6353e2adcea9fdb Signed-off-by: re2429 --- diff --git a/jjb/shell/build-docker.sh b/jjb/shell/build-docker.sh index 7656d28..b5041d3 100644 --- a/jjb/shell/build-docker.sh +++ b/jjb/shell/build-docker.sh @@ -20,64 +20,74 @@ set -e -u -x -o pipefail echo '---> Starting build-docker' -case "$PROJECT" in -portal_user_interface) - CON_NAME='akraino-portal' - VERSION=`xmlstarlet sel -N "x=http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:version" AECPortalMgmt/pom.xml` - - XMLFILE="${NEXUS_URL}/service/local/repositories/snapshots/content/org/akraino/${PROJECT}/${VERSION}/maven-metadata.xml" - curl -O "${XMLFILE}" - V2=`grep value maven-metadata.xml | sed -e 's;;;' -e 's;.*;;' | uniq` - WARFILE="${NEXUS_URL}/service/local/repositories/snapshots/content/org/akraino/${PROJECT}/${VERSION}/${PROJECT}-${V2}.war" - curl -O "${WARFILE}" - - ln $(basename ${WARFILE}) AECPortalMgmt.war - ( - echo 'FROM tomcat:8.5.31' - echo 'COPY AECPortalMgmt.war /usr/local/tomcat/webapps' - ) > Dockerfile - ;; - -camunda_workflow) - CON_NAME='akraino-camunda-workflow-engine' - VERSION=`xmlstarlet sel -N "x=http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:version" akraino/pom.xml` - - XMLFILE="${NEXUS_URL}/service/local/repositories/snapshots/content/org/akraino/${PROJECT}/${VERSION}/maven-metadata.xml" - curl -O "${XMLFILE}" - V2=`grep value maven-metadata.xml | sed -e 's;;;' -e 's;.*;;' | uniq` - JARFILE="${NEXUS_URL}/service/local/repositories/snapshots/content/org/akraino/${PROJECT}/${VERSION}/${PROJECT}-${V2}.jar" - curl -O ${JARFILE} - ;; - -postgres_db_schema) - CON_NAME='akraino_schema_db' - source $WORKSPACE/version.properties - - # Note: for some reason the project name is in the path twice for tar files - XMLFILE="${NEXUS_URL}/service/local/repositories/snapshots/content/org/akraino/yaml_builds/yaml_builds/${VERSION}/maven-metadata.xml" - curl -O "${XMLFILE}" - V2=`grep value maven-metadata.xml | sed -e 's;;;' -e 's;.*;;' | uniq` - TGZFILE="${NEXUS_URL}/service/local/repositories/snapshots/content/org/akraino/yaml_builds/yaml_builds/${VERSION}/yaml_builds-${V2}.tgz" - curl -O "${TGZFILE}" - (mkdir yaml_builds; cd yaml_builds; tar xfv ../$(basename ${TGZFILE})) - mv yaml_builds/templates akraino-j2templates - ;; - -*) - echo unknown project "$PROJECT" - exit 1 - ;; -esac - -# Append stream, if it is not the master stream -if [ "${STREAM}" != "master" ] +if [ -f Dockerfile -a -x build-container.sh ] then - VERSION="${VERSION}-${STREAM}" -fi -# Build and push the Docker container -docker build -f Dockerfile -t ${CON_NAME}:${VERSION} . -docker tag ${CON_NAME}:${VERSION} ${DOCKER_REPO}/${CON_NAME}:${VERSION} -docker push ${DOCKER_REPO}/${CON_NAME}:${VERSION} + # Let the project owner determine how the container is built. + bash ./build-container.sh + +else + + case "$PROJECT" in + portal_user_interface) + CON_NAME='akraino-portal' + VERSION=`xmlstarlet sel -N "x=http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:version" AECPortalMgmt/pom.xml` + + XMLFILE="${NEXUS_URL}/service/local/repositories/snapshots/content/org/akraino/${PROJECT}/${VERSION}/maven-metadata.xml" + curl -O "${XMLFILE}" + V2=`grep value maven-metadata.xml | sed -e 's;;;' -e 's;.*;;' | uniq` + WARFILE="${NEXUS_URL}/service/local/repositories/snapshots/content/org/akraino/${PROJECT}/${VERSION}/${PROJECT}-${V2}.war" + curl -O "${WARFILE}" + + ln $(basename ${WARFILE}) AECPortalMgmt.war + ( + echo 'FROM tomcat:8.5.31' + echo 'COPY AECPortalMgmt.war /usr/local/tomcat/webapps' + ) > Dockerfile + ;; + + camunda_workflow) + CON_NAME='akraino-camunda-workflow-engine' + VERSION=`xmlstarlet sel -N "x=http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:version" akraino/pom.xml` + + XMLFILE="${NEXUS_URL}/service/local/repositories/snapshots/content/org/akraino/${PROJECT}/${VERSION}/maven-metadata.xml" + curl -O "${XMLFILE}" + V2=`grep value maven-metadata.xml | sed -e 's;;;' -e 's;.*;;' | uniq` + JARFILE="${NEXUS_URL}/service/local/repositories/snapshots/content/org/akraino/${PROJECT}/${VERSION}/${PROJECT}-${V2}.jar" + curl -O ${JARFILE} + ;; + + postgres_db_schema) + CON_NAME='akraino_schema_db' + source $WORKSPACE/version.properties + + # Note: for some reason the project name is in the path twice for tar files + XMLFILE="${NEXUS_URL}/service/local/repositories/snapshots/content/org/akraino/yaml_builds/yaml_builds/${VERSION}/maven-metadata.xml" + curl -O "${XMLFILE}" + V2=`grep value maven-metadata.xml | sed -e 's;;;' -e 's;.*;;' | uniq` + TGZFILE="${NEXUS_URL}/service/local/repositories/snapshots/content/org/akraino/yaml_builds/yaml_builds/${VERSION}/yaml_builds-${V2}.tgz" + curl -O "${TGZFILE}" + (mkdir yaml_builds; cd yaml_builds; tar xfv ../$(basename ${TGZFILE})) + mv yaml_builds/templates akraino-j2templates + ;; + + *) + echo unknown project "$PROJECT" + exit 1 + ;; + esac + + # Append stream, if it is not the master stream + if [ "${STREAM}" != "master" ] + then + VERSION="${VERSION}-${STREAM}" + fi + + # Build and push the Docker container + docker build -f Dockerfile -t ${CON_NAME}:${VERSION} . + docker tag ${CON_NAME}:${VERSION} ${DOCKER_REPO}/${CON_NAME}:${VERSION} + docker push ${DOCKER_REPO}/${CON_NAME}:${VERSION} + +fi set +u +x