blob: a5da09d836241c553fcb00698400fad57ca27a93 [file] [log] [blame]
adheli.tavares1f339f82023-02-17 15:14:07 +00001#!/bin/bash
2#
3# ============LICENSE_START====================================================
adheli.tavares80e382e2024-05-01 14:08:35 +01004# Copyright (C) 2022-2024 Nordix Foundation.
adheli.tavares1f339f82023-02-17 15:14:07 +00005# =============================================================================
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 *)
adheli.tavares1f339f82023-02-17 15:14:07 +000053 component="$1"
54 shift
55 ;;
56 esac
57done
58
adheli.tavares5980fb42023-03-16 16:31:11 +000059cd ${COMPOSE_FOLDER}
60
adheli.tavares1f339f82023-02-17 15:14:07 +000061echo "Configuring docker compose..."
adheli.tavares5980fb42023-03-16 16:31:11 +000062source export-ports.sh > /dev/null 2>&1
63source get-versions.sh > /dev/null 2>&1
adheli.tavares1f339f82023-02-17 15:14:07 +000064
65# in case of csit running for PAP (groups should be for pap) but starts apex-pdp for dependencies.
66if [ -z "$PROJECT" ]; then
adheli.tavaresc244ab02023-03-13 16:55:02 +000067 export PROJECT=$component
adheli.tavares1f339f82023-02-17 15:14:07 +000068fi
69
adheli.tavares80e382e2024-05-01 14:08:35 +010070# docker compose fails when not running CSIT
71if [ -z "$ROBOT_LOG_DIR" ]; then
72 export ROBOT_LOG_DIR=/tmp/
73fi
74
adheli.tavares1f339f82023-02-17 15:14:07 +000075if [ -n "$component" ]; then
adheli.tavares5980fb42023-03-16 16:31:11 +000076 if [ "$component" == "logs" ]; then
77 echo "Collecting logs..."
adheli.tavares80e382e2024-05-01 14:08:35 +010078 docker compose logs > docker-compose.log
adheli.tavares5980fb42023-03-16 16:31:11 +000079 elif [ "$grafana" = true ]; then
adheli.tavares1f339f82023-02-17 15:14:07 +000080 echo "Starting ${component} application with Grafana"
adheli.tavares80e382e2024-05-01 14:08:35 +010081 docker compose up -d "${component}" grafana
adheli.tavares1f339f82023-02-17 15:14:07 +000082 echo "Prometheus server: http://localhost:${PROMETHEUS_PORT}"
83 echo "Grafana server: http://localhost:${GRAFANA_PORT}"
84 elif [ "$gui" = true ]; then
85 echo "Starting application with gui..."
adheli.tavares80e382e2024-05-01 14:08:35 +010086 docker compose -f docker-compose.yml -f docker-compose.gui.yml up -d "${component}" policy-gui
adheli.tavares1f339f82023-02-17 15:14:07 +000087 echo "Clamp GUI: https://localhost:2445/clamp"
88 else
89 echo "Starting ${component} application"
adheli.tavares80e382e2024-05-01 14:08:35 +010090 docker compose up -d "${component}"
adheli.tavares1f339f82023-02-17 15:14:07 +000091 fi
92else
adheli.tavaresc244ab02023-03-13 16:55:02 +000093 export PROJECT=api # api has groups.json complete with all 3 pdps
adheli.tavares1f339f82023-02-17 15:14:07 +000094 if [ "$gui" = true ]; then
95 echo "Starting application with gui..."
adheli.tavares80e382e2024-05-01 14:08:35 +010096 docker compose -f docker-compose.yml -f docker-compose.gui.yml up -d
adheli.tavares1f339f82023-02-17 15:14:07 +000097 echo "Clamp GUI: https://localhost:2445/clamp"
98 else
99 echo "Starting all components..."
adheli.tavares80e382e2024-05-01 14:08:35 +0100100 docker compose up -d
adheli.tavares1f339f82023-02-17 15:14:07 +0000101 fi
102fi
adheli.tavares5980fb42023-03-16 16:31:11 +0000103
104cd ${WORKSPACE}