summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDileep Ranganathan <dileep.ranganathan@intel.com>2018-07-23 07:16:25 -0700
committerDileep Ranganathan <dileep.ranganathan@intel.com>2018-07-25 17:00:18 -0700
commitabeb634c05d63739e27d05534e5c03cefffd8504 (patch)
treefb6105e6521f36b7b6620321164231adf1eebf60
parenta337408acfa590f540742d780be12619f8c1694b (diff)
Fix Docker image to use the nexus artifacts
Fixed Docker image to use the nexus artifacts instead of building from source. Added proxy support. Updated the Docker image version for Casablanca. Change-Id: I42de44b5c09992822696b1e12344ac6fde51373d Issue-ID: OPTFRA-301 Signed-off-by: Dileep Ranganathan <dileep.ranganathan@intel.com>
-rwxr-xr-xbuild-dockers.sh78
-rwxr-xr-xconductor/docker/Dockerfile25
-rwxr-xr-xrun-dockers.sh10
-rw-r--r--version.properties4
4 files changed, 84 insertions, 33 deletions
diff --git a/build-dockers.sh b/build-dockers.sh
index b531542..f2b3561 100755
--- a/build-dockers.sh
+++ b/build-dockers.sh
@@ -1,36 +1,76 @@
#!/bin/bash
+
+# The script starts in the root folder of the repo, which has the following outline
+# We fetch the version information from version.properties, build docker files and
+# do a docker push. Since the job will be run under Jenkins, it will have the Nexus
+# credentials
+
+set -e
+
BUILD_ARGS="--no-cache"
ORG="onap"
-VERSION="1.1.1"
-STAGING="1.1.1-STAGING"
PROJECT="optf-has"
DOCKER_REPOSITORY="nexus3.onap.org:10003"
IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}"
-TIMESTAMP=$(date +"%Y%m%dT%H%M%S")
-
+
+# Version properties
+source version.properties
+VERSION=$release_version
+SNAPSHOT=$snapshot_version
+STAGING=${release_version}-STAGING
+TIMESTAMP=$(date +"%Y%m%dT%H%M%S")Z
+
if [ $HTTP_PROXY ]; then
-BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
+ BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
fi
if [ $HTTPS_PROXY ]; then
BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
fi
-
-function build_image(){
- echo Building Image
- docker build -t ${IMAGE_NAME}:${VERSION} -t ${IMAGE_NAME}:latest -t ${IMAGE_NAME}:${STAGING} conductor/docker
- echo ... Built
+
+function log_ts() { # Log message with timestamp
+ echo [DEBUG LOG at $(date -u +%Y%m%d:%H%M%S)] "$@"
}
-function push_image(){
- echo Pushing image starts.
- build_image
+function get_artifact_version() {
+ log_ts Get Maven Artifact version from pom.xml
+ MVN_ARTIFACT_VERSION=`echo -e "setns x=http://maven.apache.org/POM/4.0.0 \n xpath /x:project/x:version/text() "| xmllint --shell conductor/pom.xml | grep content | sed 's/.*content=//'`
+ log_ts Maven artifact version for HAS is $MVN_ARTIFACT_VERSION
+ if [[ "$MVN_ARTIFACT_VERSION" =~ SNAPSHOT ]]; then
+ log_ts "REPO is snapshots";
+ REPO=snapshots
+ else
+ log_ts "REPO is releases";
+ REPO=releases
+ fi
+ BUILD_ARGS+=" --build-arg REPO=${REPO}"
+ BUILD_ARGS+=" --build-arg MVN_ARTIFACT_VERSION=${MVN_ARTIFACT_VERSION}"
+}
+
+function build_image() {
+ log_ts Building Image in folder: $PWD with build arguments ${BUILD_ARGS}
+ docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest conductor/docker
+ log_ts ... Built
+}
- docker push ${IMAGE_NAME}:${VERSION}
- docker push ${IMAGE_NAME}:latest
- docker push ${IMAGE_NAME}:STAGING
+function tag_image() {
+ log_ts Tagging images: ${IMAGE_NAME}:\{$SNAPSHOT-${TIMESTAMP},$STAGING-${TIMESTAMP},latest\}
+ docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${SNAPSHOT}-${TIMESTAMP}
+ docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${STAGING}-${TIMESTAMP}
+ docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:latest
+ log_ts ... Tagged images
+}
- echo ... Pushed $1
+function push_image(){
+ log_ts Pushing images: ${IMAGE_NAME}:\{$SNAPSHOT-${TIMESTAMP},$STAGING-${TIMESTAMP},latest\}
+ docker push ${IMAGE_NAME}:${SNAPSHOT}-${TIMESTAMP}
+ docker push ${IMAGE_NAME}:${STAGING}-${TIMESTAMP}
+ docker push ${IMAGE_NAME}:latest
+ log_ts ... Pushed images
}
-push_image
-
+(
+ get_artifact_version
+ build_image
+ tag_image
+ push_image
+) \ No newline at end of file
diff --git a/conductor/docker/Dockerfile b/conductor/docker/Dockerfile
index 693e458..0222c9f 100755
--- a/conductor/docker/Dockerfile
+++ b/conductor/docker/Dockerfile
@@ -16,17 +16,28 @@
# -------------------------------------------------------------------------
FROM python:2.7
+
+ARG MVN_ARTIFACT_VERSION
+ARG REPO
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
ENV CON_ADDR "127.0.0.1"
ENV CON_PORT "8091"
-EXPOSE 8091
+EXPOSE ${CON_PORT}
RUN apt-get update && apt-get --assume-yes install python-setuptools && \
-apt-get install -y unzip && \
-apt-get install -y curl && \
-apt-get install -y wget
+apt-get install -y unzip curl wget git vim
+
+# HAS
+WORKDIR /opt/has
+RUN wget -O /opt/has.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.optf.has&a=optf-has-conductor&e=zip&v=${MVN_ARTIFACT_VERSION}" && \
+ unzip -q -o -B /opt/has.zip -d /opt/has && \
+ rm -f /opt/has.zip
+RUN mkdir -p /var/log/onap/optf/has/
-RUN git clone https://gerrit.onap.org/r/optf/has \
- && git checkout beijing
-RUN cd ./has/conductor/ && pip install -e .
+RUN cd /opt/has/conductor/ && git init && pip install -e .
COPY api_paste.ini /usr/local/bin/api_paste.ini
diff --git a/run-dockers.sh b/run-dockers.sh
index cd8f763..5efb080 100755
--- a/run-dockers.sh
+++ b/run-dockers.sh
@@ -86,9 +86,9 @@ fi
echo Value is .... $COND_CONF $LOG_FILE
echo Attempting to run multiple containers on image .... ${IMAGE_NAME}
docker login -u anonymous -p anonymous ${DOCKER_REPOSITORY}
-docker run -d --name controller -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf ${IMAGE_NAME}:${VERSION} python /usr/local/bin/conductor-controller --config-file=/usr/local/bin/conductor.conf
-docker run -d --name api -p "8091:8091" -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf ${IMAGE_NAME}:${VERSION} python /usr/local/bin/conductor-api --port=8091 -- --config-file=/usr/local/bin/conductor.conf
-docker run -d --name solver -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf ${IMAGE_NAME}:${VERSION} python /usr/local/bin/conductor-solver --config-file=/usr/local/bin/conductor.conf
-docker run -d --name reservation -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf ${IMAGE_NAME}:${VERSION} python /usr/local/bin/conductor-reservation --config-file=/usr/local/bin/conductor.conf
-docker run -d --name data -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf -v $CERT:/usr/local/bin/aai_cert.cer -v $KEY:/usr/local/bin/aai_key.key -v $BUNDLE:/usr/local/bin/AAF_RootCA.cer ${IMAGE_NAME}:${VERSION} python /usr/local/bin/conductor-data --config-file=/usr/local/bin/conductor.conf
+docker run -d --name controller -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf ${IMAGE_NAME}:latest python /usr/local/bin/conductor-controller --config-file=/usr/local/bin/conductor.conf
+docker run -d --name api -p "8091:8091" -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf ${IMAGE_NAME}:latest python /usr/local/bin/conductor-api --port=8091 -- --config-file=/usr/local/bin/conductor.conf
+docker run -d --name solver -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf ${IMAGE_NAME}:latest python /usr/local/bin/conductor-solver --config-file=/usr/local/bin/conductor.conf
+docker run -d --name reservation -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf ${IMAGE_NAME}:latest python /usr/local/bin/conductor-reservation --config-file=/usr/local/bin/conductor.conf
+docker run -d --name data -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf -v $CERT:/usr/local/bin/aai_cert.cer -v $KEY:/usr/local/bin/aai_key.key -v $BUNDLE:/usr/local/bin/AAF_RootCA.cer ${IMAGE_NAME}:latest python /usr/local/bin/conductor-data --config-file=/usr/local/bin/conductor.conf
diff --git a/version.properties b/version.properties
index c7d78b7..2217466 100644
--- a/version.properties
+++ b/version.properties
@@ -18,8 +18,8 @@
#
major=1
-minor=1
-patch=1
+minor=2
+patch=0
base_version=${major}.${minor}.${patch}