blob: 7237a1fbc28615e1ac146271a8bb57c2161b9317 [file] [log] [blame]
Eric Debeaubab2f612018-04-16 19:56:04 +00001#!/bin/bash
2# ========================================================================
3# Copyright (c) 2018 Orange
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# ========================================================================
16
Quoc Nghia Nguyenf1b29332018-04-17 10:54:31 +020017NEXUS_USERNAME=docker
18NEXUS_PASSWD=docker
19NEXUS_DOCKER_REPO=nexus3.onap.org:10001
20DOCKER_IMAGE_VERSION=latest
Eric Debeaubab2f612018-04-16 19:56:04 +000021
22echo "This is ${WORKSPACE}/test/csit/scripts/externalapi-nbi/start_nbi_containers.sh"
23
24# Create directory
25mkdir -p $WORKSPACE/externalapi-nbi
26cd $WORKSPACE/externalapi-nbi
27
28# Fetch the latest docker-compose.yml
Quoc Nghia Nguyenf1b29332018-04-17 10:54:31 +020029wget -O docker-compose.yml 'https://git.onap.org/externalapi/nbi/plain/docker-compose.yml?h=master'
Eric Debeaubab2f612018-04-16 19:56:04 +000030
31# Pull the nbi docker image from nexus
32# MariaDB and mongoDB will be pulled automatically from docker.io during docker-compose
33docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
34docker pull $NEXUS_DOCKER_REPO/onap/externalapi/nbi:$DOCKER_IMAGE_VERSION
35
36# Start nbi, MariaDB and MongoDB containers with docker compose and nbi/docker-compose.yml
Quoc Nghia Nguyenf1b29332018-04-17 10:54:31 +020037docker-compose up -d mariadb mongo && sleep 5 # to ensure that these services are ready for connections
38docker-compose up -d nbi
Eric Debeaua09ce2b2018-04-18 20:53:01 +000039
40NBI_CONTAINER_NAME=$(docker-compose ps 2> /dev/null | tail -n+3 | tr -s ' ' | cut -d' ' -f1 | grep _nbi_)
41NBI_IP=$(docker inspect $NBI_CONTAINER_NAME --format='{{ range .NetworkSettings.Networks }}{{ .IPAddress }}{{ end }}')
42
43echo "IP address for NBI main container ($NBI_CONTAINER_NAME) is set to ${NBI_IP}."
44
45# Wait for initialization
46for i in {1..30}; do
47 curl -sS ${NBI_IP}:8080 > /dev/null 2>&1 && break
48 echo sleep $i
49 sleep $i
50done
51