Add container script for hw layer test
[validation.git] / docker / ui / deploy.sh
1 #!/bin/bash
2 #
3 # Copyright (c) 2019 AT&T Intellectual Property.  All other rights reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 CONTAINER_NAME="validation-ui"
18 REGISTRY=akraino
19 NAME=validation
20 TAG_PRE=`echo "${PWD##*/}"`
21 TAG_VER=latest
22 HOST_ARCH=amd64
23 postgres_db_user_pwd=""
24 jenkins_url=""
25 jenkins_user_name=""
26 jenkins_user_pwd=""
27 jenkins_job_name=""
28 nexus_results_url=""
29 proxy_ip=""
30 proxy_port=""
31
32 # get the architecture of the host
33 if [ "`uname -m`" = "aarch64" ]
34   then
35     HOST_ARCH=arm64
36 fi
37
38 for ARGUMENT in "$@"
39 do
40     KEY=$(echo $ARGUMENT | cut -f1 -d=)
41     VALUE=$(echo $ARGUMENT | cut -f2 -d=)
42     case "$KEY" in
43             REGISTRY)              REGISTRY=${VALUE} ;;
44             NAME)    NAME=${VALUE} ;;
45             TAG_VER)    TAG_VER=${VALUE} ;;
46             postgres_db_user_pwd)    postgres_db_user_pwd=${VALUE} ;;
47             jenkins_url)    jenkins_url=${VALUE} ;;
48             jenkins_user_name)    jenkins_user_name=${VALUE} ;;
49             jenkins_user_pwd)    jenkins_user_pwd=${VALUE} ;;
50             jenkins_job_name)    jenkins_job_name=${VALUE} ;;
51             nexus_results_url)    nexus_results_url=${VALUE} ;;
52             proxy_ip)    proxy_ip=${VALUE} ;;
53             proxy_port)    proxy_port=${VALUE} ;;
54             *)
55     esac
56 done
57
58 if [ -z "$postgres_db_user_pwd" ]
59   then
60     echo "ERROR: You must specify the postgresql root user password"
61     exit 1
62 fi
63
64 if [ -z "$jenkins_url" ]
65   then
66     echo "ERROR: You must specify the Jenkins Url"
67     exit 1
68 fi
69
70 if [ -z "$jenkins_user_name" ]
71   then
72     echo "ERROR: You must specify the Jenkins username"
73     exit 1
74 fi
75
76 if [ -z "$jenkins_user_pwd" ]
77   then
78     echo "ERROR: You must specify the Jenkins user password"
79     exit 1
80 fi
81
82 if [ -z "$jenkins_job_name" ]
83   then
84     echo "ERROR: You must specify the Jenkins job name"
85     exit 1
86 fi
87
88 if [ -z "$nexus_results_url" ]
89   then
90     echo "ERROR: You must specify the Nexus Url"
91     exit 1
92 fi
93
94 IMAGE="$REGISTRY"/"$NAME":"$TAG_PRE"-"$HOST_ARCH"-"$TAG_VER"
95 docker run --name $CONTAINER_NAME --network="host" -it --rm -e postgres_db_user_pwd="$postgres_db_user_pwd" -e jenkins_url="$jenkins_url" -e jenkins_user_name="$jenkins_user_name" -e jenkins_user_pwd="$jenkins_user_pwd" -e jenkins_job_name="$jenkins_job_name" -e nexus_results_url="$nexus_results_url" -e proxy_ip="$proxy_ip" -e proxy_port="$proxy_port" $IMAGE
96 sleep 10