UI adaptation for supporting ONAP portal SDK
[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
18 CONTAINER_NAME="akraino-validation-ui"
19 # Image data
20 REGISTRY=akraino
21 NAME=validation
22 TAG_PRE=ui
23 TAG_VER=latest
24 # Container input parameters
25 MARIADB_ROOT_PASSWORD=""
26 JENKINS_URL=""
27 JENKINS_USERNAME=""
28 JENKINS_USER_PASSWORD=""
29 JENKINS_JOB_NAME=""
30 DB_CONNECTION_URL=""
31 NEXUS_PROXY=""
32 JENKINS_PROXY=""
33
34 for ARGUMENT in "$@"
35 do
36     KEY=$(echo $ARGUMENT | cut -f1 -d=)
37     VALUE=$(echo $ARGUMENT | cut -f2 -d=)
38     case "$KEY" in
39             REGISTRY)              REGISTRY=${VALUE} ;;
40             NAME)    NAME=${VALUE} ;;
41             TAG_PRE)    TAG_PRE=${VALUE} ;;
42             TAG_VER)    TAG_VER=${VALUE} ;;
43             MARIADB_ROOT_PASSWORD)    MARIADB_ROOT_PASSWORD=${VALUE} ;;
44             JENKINS_URL)    JENKINS_URL=${VALUE} ;;
45             JENKINS_USERNAME)    JENKINS_USERNAME=${VALUE} ;;
46             JENKINS_USER_PASSWORD)    JENKINS_USER_PASSWORD=${VALUE} ;;
47             JENKINS_JOB_NAME)    JENKINS_JOB_NAME=${VALUE} ;;
48             DB_CONNECTION_URL)    DB_CONNECTION_URL=${VALUE} ;;
49             CONTAINER_NAME)    CONTAINER_NAME=${VALUE} ;;
50             NEXUS_PROXY) NEXUS_PROXY=${VALUE} ;;
51             JENKINS_PROXY) JENKINS_PROXY=${VALUE} ;;
52             *)
53     esac
54 done
55
56 if [ -z "$DB_CONNECTION_URL" ]
57   then
58     echo "ERROR: You must specify the database connection url"
59     exit 1
60 fi
61
62 if [ -z "$MARIADB_ROOT_PASSWORD" ]
63   then
64     echo "ERROR: You must specify the mariadb root user password"
65     exit 1
66 fi
67
68 if [ -z "$JENKINS_URL" ]
69   then
70     echo "ERROR: You must specify the Jenkins Url"
71     exit 1
72 fi
73
74 if [ -z "$JENKINS_USERNAME" ]
75   then
76     echo "ERROR: You must specify the Jenkins username"
77     exit 1
78 fi
79
80 if [ -z "$JENKINS_USER_PASSWORD" ]
81   then
82     echo "ERROR: You must specify the Jenkins user password"
83     exit 1
84 fi
85
86 if [ -z "$JENKINS_JOB_NAME" ]
87   then
88     echo "ERROR: You must specify the Jenkins job name"
89     exit 1
90 fi
91
92 IMAGE="$REGISTRY"/"$NAME":"$TAG_PRE"-"$TAG_VER"
93 docker run --name $CONTAINER_NAME --network="host" -it --rm -e DB_CONNECTION_URL="$DB_CONNECTION_URL" -e MARIADB_ROOT_PASSWORD="$MARIADB_ROOT_PASSWORD" -e JENKINS_URL="$JENKINS_URL" -e JENKINS_USERNAME="$JENKINS_USERNAME" -e JENKINS_USER_PASSWORD="$JENKINS_USER_PASSWORD" -e JENKINS_JOB_NAME="$JENKINS_JOB_NAME" -e NEXUS_PROXY="$NEXUS_PROXY" -e JENKINS_PROXY="$JENKINS_PROXY" $IMAGE
94 sleep 10