diff --git a/deploy.py b/deploy.py index be71093f1..4ce207c97 100755 --- a/deploy.py +++ b/deploy.py @@ -102,6 +102,14 @@ help="Generate config files to point to the live cluster so we don`t need to run the cluster locally, only the website", ) +config_parser.add_argument( + "--live-host", + default="main.loculus.org", + help="The live server that should be pointed to, if --from-live is set", +) + + + args = parser.parse_args() @@ -128,7 +136,7 @@ def main(): elif args.subcommand == "upgrade": handle_helm_upgrade() elif args.subcommand == "config": - generate_configs(args.from_live) + generate_configs(args.from_live, args.live_host) def handle_cluster(): @@ -247,9 +255,10 @@ def get_codespace_name(): return os.environ.get("CODESPACE_NAME", None) -def generate_configs(from_live=False): +def generate_configs(from_live, live_host): temp_dir_path = Path(tempfile.mkdtemp()) + print(f"Unprocessed config available in temp dir: {temp_dir_path}") helm_chart = str(HELM_CHART_DIR) @@ -264,6 +273,7 @@ def generate_configs(from_live=False): backend_config_path, codespace_name, from_live, + live_host ) website_config_path = temp_dir_path / "website_config.json" @@ -273,6 +283,7 @@ def generate_configs(from_live=False): website_config_path, codespace_name, from_live, + live_host ) runtime_config_path = temp_dir_path / "runtime_config.json" @@ -282,6 +293,7 @@ def generate_configs(from_live=False): runtime_config_path, codespace_name, from_live, + live_host ) ingest_configmap_path = temp_dir_path / "config.yaml" @@ -293,7 +305,8 @@ def generate_configs(from_live=False): ingest_configmap_path, codespace_name, from_live, - ingest_configout_path, + live_host, + ingest_configout_path ) prepro_configmap_path = temp_dir_path / "preprocessing-config.yaml" @@ -305,7 +318,8 @@ def generate_configs(from_live=False): prepro_configmap_path, codespace_name, from_live, - prepro_configout_path, + live_host, + prepro_configout_path ) run_command( @@ -325,8 +339,14 @@ def generate_config( configmap_path, codespace_name=None, from_live=False, + live_host=None, output_path=None, ): + if from_live and live_host: + number_of_dots = live_host.count(".") + if number_of_dots <= 2: # this is an imperfect hack + raise ValueError("Currently only subdomains are supported as live-hosts") + # To be able to cope with top level domains we need more logic to use the right subdomain separator - but we should probably avoid this anyway as we shouldn't use production domains helm_template_cmd = [ "helm", "template", @@ -346,7 +366,7 @@ def generate_config( helm_template_cmd.extend(["--set", "disableBackend=true"]) if from_live: helm_template_cmd.extend(["--set", "environment=server"]) - helm_template_cmd.extend(["--set", "host=main.loculus.org"]) + helm_template_cmd.extend(["--set", f"host={live_host}"]) helm_template_cmd.extend(["--set", "usePublicRuntimeConfigAsServerSide=true"]) else: helm_template_cmd.extend(["--set", "environment=local"])