-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathwait-for-plugins-and-start.sh
More file actions
executable file
·67 lines (54 loc) · 2.36 KB
/
wait-for-plugins-and-start.sh
File metadata and controls
executable file
·67 lines (54 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
set -euo pipefail
# This script is a workaround for podman-compose absence of support for depends_on
# Entrypoint for the main RHDH container.
# Waits for the dynamic plugin config to be generated,
# then starts the Backstage backend with appropriate config files.
#
# If user-supplied override files for catalog entities (users/components) exist,
# this script replaces their paths in the base config accordingly.
DYNAMIC_PLUGINS_CONFIG="dynamic-plugins-root/app-config.dynamic-plugins.yaml"
DEFAULT_APP_CONFIG="configs/app-config/app-config.yaml"
PATCHED_APP_CONFIG="generated/app-config.patched.yaml"
USER_APP_CONFIG="configs/app-config/app-config.local.yaml"
LIGHTSPEED_APP_CONFIG="developer-lightspeed/configs/app-config/app-config.lightspeed.local.yaml"
LEGACY_USER_APP_CONFIG="configs/app-config.local.yaml"
USERS_OVERRIDE="configs/catalog-entities/users.override.yaml"
mkdir -p generated
cp -f "$DEFAULT_APP_CONFIG" "$PATCHED_APP_CONFIG"
# Wait until the dynamic plugin config is ready
while [ ! -f "$DYNAMIC_PLUGINS_CONFIG" ]; do
echo "Waiting for $DYNAMIC_PLUGINS_CONFIG to be created by install-dynamic-plugins container ..."
sleep 2
done
# Apply overrides by replacing target paths in the patched config
if [ -f "$USERS_OVERRIDE" ]; then
echo "Applying users override"
sed -i "s|/opt/app-root/src/configs/catalog-entities/users.yaml|/opt/app-root/src/$USERS_OVERRIDE|" "$PATCHED_APP_CONFIG"
fi
# Add local config if available
EXTRA_CONFIGS=""
if [ -f "$USER_APP_CONFIG" ]; then
echo "Using user config: $USER_APP_CONFIG"
EXTRA_CONFIGS="$USER_APP_CONFIG"
elif [ -f "$LEGACY_USER_APP_CONFIG" ]; then
echo "[warn] Using legacy app-config.local.yaml. This is deprecated. Please migrate to $USER_APP_CONFIG."
EXTRA_CONFIGS="$LEGACY_USER_APP_CONFIG"
fi
if [ -f "$LIGHTSPEED_APP_CONFIG" ]; then
echo "Using lightspeed config: $LIGHTSPEED_APP_CONFIG"
EXTRA_CONFIGS="$EXTRA_CONFIGS $LIGHTSPEED_APP_CONFIG"
fi
EXTRA_CLI_ARGS=""
for config in $EXTRA_CONFIGS; do
EXTRA_CLI_ARGS="$EXTRA_CLI_ARGS --config $config"
done
# Start Backstage backend
# Allows variable expansion for CLI args
# shellcheck disable=SC2086
exec node packages/backend --no-node-snapshot \
--config "app-config.yaml" \
--config app-config.example.yaml \
--config app-config.example.production.yaml \
--config "$DYNAMIC_PLUGINS_CONFIG" \
--config "$PATCHED_APP_CONFIG" $EXTRA_CLI_ARGS