blob: 49006f110520ec495346f16b258319faf98dedaf [file] [log] [blame]
adheli.tavares1f339f82023-02-17 15:14:07 +00001#!/bin/bash
2#
3# ============LICENSE_START====================================================
4# Copyright (C) 2022-2023 Nordix Foundation.
5# =============================================================================
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18# SPDX-License-Identifier: Apache-2.0
19# ============LICENSE_END======================================================
20
21#Usage: $0 [policy-component] [OPTIONS]"
22#" OPTIONS:"
23#" --grafana start the docker compose with grafana"
24#" --gui start the docker compose with gui"
25#" no policy-component will start all components"
26
27if [ -z "${WORKSPACE}" ]; then
28 WORKSPACE=$(git rev-parse --show-toplevel)
29 export WORKSPACE
30fi
31COMPOSE_FOLDER="${WORKSPACE}"/compose
32
33# Set default values for the options
34grafana=false
35gui=false
36
37# Parse the command-line arguments
38while [[ $# -gt 0 ]]
39do
40 key="$1"
41
42 case $key in
43 --grafana)
44 grafana=true
45 shift
46 ;;
47 --gui)
48 gui=true
49 shift 2
50 break;
51 ;;
52 *)
53 echo "$1"
54 component="$1"
55 shift
56 ;;
57 esac
58done
59
adheli.tavares5980fb42023-03-16 16:31:11 +000060cd ${COMPOSE_FOLDER}
61
adheli.tavares1f339f82023-02-17 15:14:07 +000062echo "Configuring docker compose..."
adheli.tavares5980fb42023-03-16 16:31:11 +000063source export-ports.sh > /dev/null 2>&1
64source get-versions.sh > /dev/null 2>&1
adheli.tavares1f339f82023-02-17 15:14:07 +000065
66# in case of csit running for PAP (groups should be for pap) but starts apex-pdp for dependencies.
67if [ -z "$PROJECT" ]; then
adheli.tavaresc244ab02023-03-13 16:55:02 +000068 export PROJECT=$component
adheli.tavares1f339f82023-02-17 15:14:07 +000069fi
70
71if [ -n "$component" ]; then
adheli.tavares5980fb42023-03-16 16:31:11 +000072 if [ "$component" == "logs" ]; then
73 echo "Collecting logs..."
74 docker-compose logs > docker-compose.log
75 elif [ "$grafana" = true ]; then
adheli.tavares1f339f82023-02-17 15:14:07 +000076 echo "Starting ${component} application with Grafana"
adheli.tavares5980fb42023-03-16 16:31:11 +000077 docker-compose up -d "${component}" grafana
adheli.tavares1f339f82023-02-17 15:14:07 +000078 echo "Prometheus server: http://localhost:${PROMETHEUS_PORT}"
79 echo "Grafana server: http://localhost:${GRAFANA_PORT}"
80 elif [ "$gui" = true ]; then
81 echo "Starting application with gui..."
adheli.tavares5980fb42023-03-16 16:31:11 +000082 docker-compose -f docker-compose.yml -f docker-compose.gui.yml up -d "${component}" policy-gui
adheli.tavares1f339f82023-02-17 15:14:07 +000083 echo "Clamp GUI: https://localhost:2445/clamp"
84 else
85 echo "Starting ${component} application"
adheli.tavares5980fb42023-03-16 16:31:11 +000086 docker-compose up -d "${component}"
adheli.tavares1f339f82023-02-17 15:14:07 +000087 fi
88else
adheli.tavaresc244ab02023-03-13 16:55:02 +000089 export PROJECT=api # api has groups.json complete with all 3 pdps
adheli.tavares1f339f82023-02-17 15:14:07 +000090 if [ "$gui" = true ]; then
91 echo "Starting application with gui..."
adheli.tavares5980fb42023-03-16 16:31:11 +000092 docker-compose -f docker-compose.yml -f docker-compose.gui.yml up -d
adheli.tavares1f339f82023-02-17 15:14:07 +000093 echo "Clamp GUI: https://localhost:2445/clamp"
94 else
95 echo "Starting all components..."
adheli.tavares5980fb42023-03-16 16:31:11 +000096 docker-compose up -d
adheli.tavares1f339f82023-02-17 15:14:07 +000097 fi
98fi
adheli.tavares5980fb42023-03-16 16:31:11 +000099
100cd ${WORKSPACE}