From 2717274da6fd11e9ce4230e16ad4e064c9e3ebe7 Mon Sep 17 00:00:00 2001
From: Arthur Le Bars <arthur.le-bars@sb-roscoff.fr>
Date: Tue, 9 Mar 2021 11:17:47 +0100
Subject: [PATCH] using localhost rule to connect to instance via http

---
 run_workflow_phaeoexplorer.py              | 18 +++++++-----------
 templates/gspecies_compose_template.yml.j2 |  2 ++
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/run_workflow_phaeoexplorer.py b/run_workflow_phaeoexplorer.py
index 4e9a35f..90ab7fe 100644
--- a/run_workflow_phaeoexplorer.py
+++ b/run_workflow_phaeoexplorer.py
@@ -483,7 +483,7 @@ class RunWorkflow(speciesData.SpeciesData):
             # In case of the Jbrowse workflow, we unfortunately have to manually edit the parameters instead of setting them
             # as runtime values, using runtime parameters makes the tool throw an internal critical error ("replace not found" error)
             if workflow_name == "Jbrowse":
-                workflow_dict["steps"]["2"]["tool_state"] = workflow_dict["steps"]["2"]["tool_state"].replace("__MENU_URL__", "http://localhost:{port}/sp/{genus_sp}/feature/{Genus}/{species}/{id}".format(port=self.config["http_port"], genus_sp=self.genus_species, Genus=self.genus_uppercase, species=self.species, id="{id}"))
+            workflow_dict["steps"]["2"]["tool_state"] = workflow_dict["steps"]["2"]["tool_state"].replace("__MENU_URL__", "https://{host}:{port}/sp/{genus_sp}/feature/{Genus}/{species}/{id}".format(host=self.config["host"], port=self.config["https_port"], genus_sp=self.genus_species, Genus=self.genus_uppercase, species=self.species, id="{id}"))
                 workflow_dict["steps"]["3"]["tool_state"] = workflow_dict["steps"]["3"]["tool_state"].replace("__FULL_NAME__", self.full_name).replace("__UNIQUE_ID__", self.abbreviation)
 
             # Import the workflow in galaxy as a dict
@@ -850,16 +850,12 @@ if __name__ == "__main__":
 
             # Parse the config yaml file
             run_workflow_for_current_organism.config = utilities.parse_config(args.config)
-             # Set the instance url attribute
-            for env_variable, value in run_workflow_for_current_organism.config.items():
-                if env_variable == "hostname":
-                    run_workflow_for_current_organism.instance_url = "http://{0}:8888/sp/{1}/galaxy/".format(
-                        value, run_workflow_for_current_organism.genus_species)
-                    break
-                else:
-                    run_workflow_for_current_organism.instance_url = "http://localhost:8888/sp/{0}_{1}/galaxy/".format(
-                        run_workflow_for_current_organism.genus_lowercase,
-                        run_workflow_for_current_organism.species)
+            # Set the instance url attribute
+            run_workflow_for_current_organism.instance_url = "http://localhost:{0}/sp/{1}_{2}/galaxy/".format(
+                run_workflow_for_current_organism.config["http_port"]
+                run_workflow_for_current_organism.genus_lowercase,
+                run_workflow_for_current_organism.species)
+
 
 
             # If input workflow is Chado_load_Tripal_synchronize.ga
diff --git a/templates/gspecies_compose_template.yml.j2 b/templates/gspecies_compose_template.yml.j2
index fd32d56..6bf0adc 100644
--- a/templates/gspecies_compose_template.yml.j2
+++ b/templates/gspecies_compose_template.yml.j2
@@ -159,6 +159,8 @@ services:
 #            - "traefik.http.routers.{{ genus_species }}-galaxy.entryPoints=webs"
             - "traefik.http.routers.{{ genus_species }}-galaxy.entryPoints=web" #lg
 #            - "traefik.http.routers.{{ genus_species }}-galaxy.middlewares=sp-auth,sp-app-trailslash,sp-app-prefix"
+            - "traefik.http.routers.{{ genus_species }}-gga_load-galaxy.rule=(Host(`localhost`) && PathPrefix(`/sp/{{ genus_species }}/galaxy`))"
+            - "traefik.http.routers.{{ genus_species }}-gga_load-galaxy.entryPoints=web"
             - "traefik.http.routers.{{ genus_species }}-galaxy.middlewares=sp-app-trailslash,sp-app-prefix" #lg
             - "traefik.http.services.{{ genus_species }}-galaxy.loadbalancer.server.port=80"
           restart_policy:
-- 
GitLab