blob: 013aba6ff10b4c1ff9eac30cecb1ff037150548d [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:"
adheli.tavaresd802fd92024-08-15 12:39:19 +010023#" --grafana start the docker compose with grafana"
24#" --mariadb start the docker compose using mariadb"
25#" --postgres [default] start the docker compose using postgres db"
adheli.tavares1f339f82023-02-17 15:14:07 +000026#" no policy-component will start all components"
27
28if [ -z "${WORKSPACE}" ]; then
29 WORKSPACE=$(git rev-parse --show-toplevel)
30 export WORKSPACE
31fi
32COMPOSE_FOLDER="${WORKSPACE}"/compose
33
34# Set default values for the options
35grafana=false
adheli.tavaresd802fd92024-08-15 12:39:19 +010036database=postgres
adheli.tavares1f339f82023-02-17 15:14:07 +000037
38# Parse the command-line arguments
39while [[ $# -gt 0 ]]
40do
41 key="$1"
42
43 case $key in
44 --grafana)
45 grafana=true
46 shift
47 ;;
adheli.tavaresd802fd92024-08-15 12:39:19 +010048 --mariadb)
49 database=mariadb
50 shift
51 ;;
52 --postgres)
53 database=postgres
54 shift
55 ;;
adheli.tavares1f339f82023-02-17 15:14:07 +000056 *)
adheli.tavares1f339f82023-02-17 15:14:07 +000057 component="$1"
58 shift
59 ;;
60 esac
61done
62
adheli.tavares5980fb42023-03-16 16:31:11 +000063cd ${COMPOSE_FOLDER}
64
adheli.tavares1f339f82023-02-17 15:14:07 +000065echo "Configuring docker compose..."
adheli.tavares5980fb42023-03-16 16:31:11 +000066source export-ports.sh > /dev/null 2>&1
67source get-versions.sh > /dev/null 2>&1
adheli.tavares1f339f82023-02-17 15:14:07 +000068
69# in case of csit running for PAP (groups should be for pap) but starts apex-pdp for dependencies.
70if [ -z "$PROJECT" ]; then
adheli.tavaresc244ab02023-03-13 16:55:02 +000071 export PROJECT=$component
adheli.tavares1f339f82023-02-17 15:14:07 +000072fi
73
adheli.tavaresd802fd92024-08-15 12:39:19 +010074export database
adheli.tavares36127472024-07-02 11:51:35 +010075
adheli.tavares1f339f82023-02-17 15:14:07 +000076if [ -n "$component" ]; then
adheli.tavaresd802fd92024-08-15 12:39:19 +010077 if [ "$grafana" = true ]; then
78 echo "Starting ${component} using ${database} + Grafana/Prometheus"
79 docker compose up -d ${component} ${database} grafana
80
adheli.tavares1f339f82023-02-17 15:14:07 +000081 echo "Prometheus server: http://localhost:${PROMETHEUS_PORT}"
82 echo "Grafana server: http://localhost:${GRAFANA_PORT}"
adheli.tavaresd802fd92024-08-15 12:39:19 +010083
adheli.tavares1f339f82023-02-17 15:14:07 +000084 else
adheli.tavaresd802fd92024-08-15 12:39:19 +010085 echo "Starting ${component} using ${database}"
86 docker compose up -d ${component} ${database}
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.tavaresd802fd92024-08-15 12:39:19 +010090 echo "Starting all components using ${database}"
adheli.tavaresdaecbb92024-07-19 13:50:04 +010091 docker compose up -d
adheli.tavares1f339f82023-02-17 15:14:07 +000092fi
adheli.tavares5980fb42023-03-16 16:31:11 +000093
94cd ${WORKSPACE}