From 172300d7bd64ea14e912af88a2c2e6e3113c5ea0 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Mon, 17 Apr 2023 20:46:05 -0600 Subject: [PATCH] Simple implementation of LACONIC_HOSTED_ENDPOINT (#342) --- .../compose/docker-compose-fixturenet-laconic-console.yml | 2 ++ .../cerc-laconic-console-host/apply-webapp-config.sh | 5 +++-- .../container-build/cerc-laconic-console-host/config.yml | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/data/compose/docker-compose-fixturenet-laconic-console.yml b/app/data/compose/docker-compose-fixturenet-laconic-console.yml index f402fa70..23185957 100644 --- a/app/data/compose/docker-compose-fixturenet-laconic-console.yml +++ b/app/data/compose/docker-compose-fixturenet-laconic-console.yml @@ -2,5 +2,7 @@ services: laconic-console: restart: unless-stopped image: cerc/laconic-console-host:local + environment: + - LACONIC_HOSTED_ENDPOINT=${LACONIC_HOSTED_ENDPOINT:-http://localhost} ports: - "80" diff --git a/app/data/container-build/cerc-laconic-console-host/apply-webapp-config.sh b/app/data/container-build/cerc-laconic-console-host/apply-webapp-config.sh index d01b655d..bf041708 100755 --- a/app/data/container-build/cerc-laconic-console-host/apply-webapp-config.sh +++ b/app/data/container-build/cerc-laconic-console-host/apply-webapp-config.sh @@ -26,9 +26,10 @@ do kv_pair=(${kv_pair_string//=/ }) template_string_to_replace=${kv_pair[0]} template_value_to_substitute=${kv_pair[1]} + template_value_to_substitute_expanded=${template_value_to_substitute//LACONIC_HOSTED_ENDPOINT/${LACONIC_HOSTED_ENDPOINT}} # Run find and sed to do the substitution of one variable over all files # See: https://stackoverflow.com/a/21479607/1701505 - echo "Substituting: ${template_string_to_replace} = ${template_value_to_substitute}" + echo "Substituting: ${template_string_to_replace} = ${template_value_to_substitute_expanded}" # Note: we do not escape our strings, on the expectation they do not container the '#' char. - find ${webapp_files_dir} -type f -exec sed -i 's#'${template_string_to_replace}'#'${template_value_to_substitute}'#g' {} + + find ${webapp_files_dir} -type f -exec sed -i 's#'${template_string_to_replace}'#'${template_value_to_substitute_expanded}'#g' {} + done diff --git a/app/data/container-build/cerc-laconic-console-host/config.yml b/app/data/container-build/cerc-laconic-console-host/config.yml index da57724a..d557ace5 100644 --- a/app/data/container-build/cerc-laconic-console-host/config.yml +++ b/app/data/container-build/cerc-laconic-console-host/config.yml @@ -2,5 +2,5 @@ services: wns: - server: 'http://localhost:9473/api' - webui: 'http://localhost:9473/console' + server: 'LACONIC_HOSTED_ENDPOINT:9473/api' + webui: 'LACONIC_HOSTED_ENDPOINT:9473/console'