summaryrefslogtreecommitdiffstats
path: root/azure/docker
diff options
context:
space:
mode:
Diffstat (limited to 'azure/docker')
-rw-r--r--azure/docker/Dockerfile29
-rw-r--r--azure/docker/build_image.sh50
-rw-r--r--azure/docker/docker-entrypoint.sh48
-rw-r--r--azure/docker/instance-config.sh48
-rw-r--r--azure/docker/instance-init.sh22
-rw-r--r--azure/docker/instance-run.sh22
6 files changed, 219 insertions, 0 deletions
diff --git a/azure/docker/Dockerfile b/azure/docker/Dockerfile
new file mode 100644
index 0000000..1b232ae
--- /dev/null
+++ b/azure/docker/Dockerfile
@@ -0,0 +1,29 @@
+FROM python:2
+
+ENV MSB_ADDR "127.0.0.1"
+ENV MSB_PORT "80"
+ENV AAI_ADDR "aai.api.simpledemo.openecomp.org"
+ENV AAI_PORT "8443"
+ENV AAI_SCHEMA_VERSION "v13"
+ENV AAI_USERNAME "AAI"
+ENV AAI_PASSWORD "AAI"
+ENV MR_ADDR "127.0.0.1"
+ENV MR_PORT "3904"
+
+EXPOSE 9004
+
+RUN apt-get update && \
+ apt-get install -y unzip && \
+ apt-get install -y curl && \
+ apt-get install -y wget
+
+
+RUN cd /opt/ && \
+ wget -q -O multicloud-azure.zip 'https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.multicloud.azure&a=multicloud-azure&v=LATEST&e=zip' && \
+ unzip multicloud-azure.zip && \
+ rm -rf multicloud-azure.zip && \
+ pip install -r azure/requirements.txt
+
+
+WORKDIR /opt
+ENTRYPOINT azure/docker/docker-entrypoint.sh
diff --git a/azure/docker/build_image.sh b/azure/docker/build_image.sh
new file mode 100644
index 0000000..24ba356
--- /dev/null
+++ b/azure/docker/build_image.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+# Copyright (c) 2018 Amdocs
+#
+# 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.
+
+DIRNAME=`dirname $0`
+DOCKER_BUILD_DIR=`cd $DIRNAME/; pwd`
+echo "DOCKER_BUILD_DIR=${DOCKER_BUILD_DIR}"
+cd ${DOCKER_BUILD_DIR}
+
+BUILD_ARGS="--no-cache"
+ORG="onap"
+VERSION="1.2.0-SNAPSHOT"
+STAGING="1.2.0-STAGING"
+PROJECT="multicloud"
+IMAGE="azure"
+DOCKER_REPOSITORY="nexus3.onap.org:10003"
+IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/${IMAGE}"
+
+if [ $HTTP_PROXY ]; then
+ 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 "Start build docker image: ${IMAGE_NAME}"
+ docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:${VERSION} -t ${IMAGE_NAME}:latest -t ${IMAGE_NAME}:${STAGING} .
+}
+
+function push_image {
+ echo "Start push docker image: ${IMAGE_NAME}"
+ docker push ${IMAGE_NAME}:${VERSION}
+ docker push ${IMAGE_NAME}:latest
+ docker push ${IMAGE_NAME}:${STAGING}
+}
+
+build_image
+push_image
diff --git a/azure/docker/docker-entrypoint.sh b/azure/docker/docker-entrypoint.sh
new file mode 100644
index 0000000..5566aff
--- /dev/null
+++ b/azure/docker/docker-entrypoint.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+# Copyright (c) 2018 Amdocs
+#
+# 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.
+
+
+if [ -z "$SERVICE_IP" ]; then
+ export SERVICE_IP=`hostname -i`
+fi
+echo
+echo Environment Variables:
+echo "SERVICE_IP=$SERVICE_IP"
+
+if [ -z "$MSB_ADDR" ]; then
+ echo "Missing required variable MSB_ADDR: Microservices Service Bus address <ip>:<port>"
+ exit 1
+fi
+echo "MSB_ADDR=$MSB_ADDR"
+echo
+
+
+echo
+
+# Configure service based on docker environment variables
+azure/docker/instance-config.sh
+
+
+# Perform one-time config
+if [ ! -e init.log ]; then
+
+ # microservice-specific one-time initialization
+ azure/docker/instance-init.sh
+
+ date > init.log
+fi
+
+# Start the microservice
+azure/docker/instance-run.sh
diff --git a/azure/docker/instance-config.sh b/azure/docker/instance-config.sh
new file mode 100644
index 0000000..6500d03
--- /dev/null
+++ b/azure/docker/instance-config.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+# Copyright (c) 2018 Amdocs
+#
+# 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.
+
+# Configure MSB IP address
+MSB_IP=`echo $MSB_ADDR | cut -d: -f 1`
+MSB_PORT=`echo $MSB_PORT | cut -d: -f 2`
+sed -i "s|MSB_SERVICE_IP.*|MSB_SERVICE_IP = '$MSB_IP'|" azure/azure/pub/config/config.py
+sed -i "s|MSB_SERVICE_PORT.*|MSB_SERVICE_PORT = '$MSB_PORT'|" azure/azure/pub/config/config.py
+sed -i "s|DB_NAME.*|DB_NAME = 'inventory'|" azure/azure/pub/config/config.py
+sed -i "s|DB_USER.*|DB_USER = 'inventory'|" azure/azure/pub/config/config.py
+sed -i "s|DB_PASSWD.*|DB_PASSWD = 'inventory'|" azure/azure/pub/config/config.py
+sed -i "s|\"ip\": \".*\"|\"ip\": \"$SERVICE_IP\"|" azure/azure/pub/config/config.py
+
+# Configure MYSQL
+if [ -z "$MYSQL_ADDR" ]; then
+ export MYSQL_IP=`hostname -i`
+ export MYSQL_PORT=3306
+ export MYSQL_ADDR=$MYSQL_IP:$MYSQL_PORT
+else
+ MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1`
+ MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2`
+fi
+echo "MYSQL_ADDR=$MYSQL_ADDR"
+sed -i "s|DB_IP.*|DB_IP = '$MYSQL_IP'|" azure/azure/pub/config/config.py
+sed -i "s|DB_PORT.*|DB_PORT = $MYSQL_PORT|" azure/azure/pub/config/config.py
+
+cat azure/azure/pub/config/config.py
+
+sed -i "s/sip=.*/sip=$SERVICE_IP/g" azure/run.sh
+sed -i "s/sip=.*/sip=$SERVICE_IP/g" azure/stop.sh
+
+# Create log directory
+logDir="/var/log/onap/multicloud/azure"
+if [ ! -x $logDir ]; then
+ mkdir -p $logDir
+fi
diff --git a/azure/docker/instance-init.sh b/azure/docker/instance-init.sh
new file mode 100644
index 0000000..cd2222c
--- /dev/null
+++ b/azure/docker/instance-init.sh
@@ -0,0 +1,22 @@
+#!/bin/bash -v
+# Copyright (c) 2018 Amdocs
+#
+# 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.
+
+# Initialize DB schema
+#./bin/initDB.sh root rootpass 3306 127.0.0.1
+
+# Install python requirements
+cd /opt/azure
+./initialize.sh
+cd /opt
diff --git a/azure/docker/instance-run.sh b/azure/docker/instance-run.sh
new file mode 100644
index 0000000..90d3e9d
--- /dev/null
+++ b/azure/docker/instance-run.sh
@@ -0,0 +1,22 @@
+#!/bin/bash -v
+# Copyright (c) 2018 Amdocs
+#
+# 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.
+
+cd ./azure
+./run.sh
+
+while [ ! -f /var/log/onap/multicloud/azure/azure.log ]; do
+ sleep 1
+done
+tail -F /var/log/onap/multicloud/azure/azure.log