adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # ============LICENSE_START==================================================== |
adheli.tavares | 80e382e | 2024-05-01 14:08:35 +0100 | [diff] [blame] | 4 | # Copyright (C) 2022-2024 Nordix Foundation. |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 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:" |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame] | 23 | #" --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.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 26 | #" no policy-component will start all components" |
| 27 | |
| 28 | if [ -z "${WORKSPACE}" ]; then |
| 29 | WORKSPACE=$(git rev-parse --show-toplevel) |
| 30 | export WORKSPACE |
| 31 | fi |
| 32 | COMPOSE_FOLDER="${WORKSPACE}"/compose |
| 33 | |
| 34 | # Set default values for the options |
| 35 | grafana=false |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame] | 36 | database=postgres |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 37 | |
| 38 | # Parse the command-line arguments |
| 39 | while [[ $# -gt 0 ]] |
| 40 | do |
| 41 | key="$1" |
| 42 | |
| 43 | case $key in |
| 44 | --grafana) |
| 45 | grafana=true |
| 46 | shift |
| 47 | ;; |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame] | 48 | --mariadb) |
| 49 | database=mariadb |
| 50 | shift |
| 51 | ;; |
| 52 | --postgres) |
| 53 | database=postgres |
| 54 | shift |
| 55 | ;; |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 56 | *) |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 57 | component="$1" |
| 58 | shift |
| 59 | ;; |
| 60 | esac |
| 61 | done |
| 62 | |
adheli.tavares | 5980fb4 | 2023-03-16 16:31:11 +0000 | [diff] [blame] | 63 | cd ${COMPOSE_FOLDER} |
| 64 | |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 65 | echo "Configuring docker compose..." |
adheli.tavares | 5980fb4 | 2023-03-16 16:31:11 +0000 | [diff] [blame] | 66 | source export-ports.sh > /dev/null 2>&1 |
| 67 | source get-versions.sh > /dev/null 2>&1 |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 68 | |
| 69 | # in case of csit running for PAP (groups should be for pap) but starts apex-pdp for dependencies. |
| 70 | if [ -z "$PROJECT" ]; then |
adheli.tavares | c244ab0 | 2023-03-13 16:55:02 +0000 | [diff] [blame] | 71 | export PROJECT=$component |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 72 | fi |
| 73 | |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame] | 74 | export database |
adheli.tavares | 3612747 | 2024-07-02 11:51:35 +0100 | [diff] [blame] | 75 | |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 76 | if [ -n "$component" ]; then |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame] | 77 | if [ "$grafana" = true ]; then |
| 78 | echo "Starting ${component} using ${database} + Grafana/Prometheus" |
| 79 | docker compose up -d ${component} ${database} grafana |
| 80 | |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 81 | echo "Prometheus server: http://localhost:${PROMETHEUS_PORT}" |
| 82 | echo "Grafana server: http://localhost:${GRAFANA_PORT}" |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame] | 83 | |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 84 | else |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame] | 85 | echo "Starting ${component} using ${database}" |
| 86 | docker compose up -d ${component} ${database} |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 87 | fi |
| 88 | else |
adheli.tavares | c244ab0 | 2023-03-13 16:55:02 +0000 | [diff] [blame] | 89 | export PROJECT=api # api has groups.json complete with all 3 pdps |
adheli.tavares | d802fd9 | 2024-08-15 12:39:19 +0100 | [diff] [blame] | 90 | echo "Starting all components using ${database}" |
adheli.tavares | daecbb9 | 2024-07-19 13:50:04 +0100 | [diff] [blame] | 91 | docker compose up -d |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 92 | fi |
adheli.tavares | 5980fb4 | 2023-03-16 16:31:11 +0000 | [diff] [blame] | 93 | |
| 94 | cd ${WORKSPACE} |