From 391f0dffc46316e97a4922fefdc3c53c04238f3d Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen.haas@lakedrops.com>
Date: Sat, 16 Sep 2023 11:43:39 +0200
Subject: [PATCH] docker/l3d#133 Add support for unlighthouse

---
 src/Handler.php                             |  1 +
 templates/docker-compose.yml.twig           |  2 +-
 templates/tests/unlighthouse.config.ts      | 13 -------------
 templates/tests/unlighthouse.config.ts.twig | 19 +++++++++++++++++++
 4 files changed, 21 insertions(+), 14 deletions(-)
 delete mode 100644 templates/tests/unlighthouse.config.ts
 create mode 100644 templates/tests/unlighthouse.config.ts.twig

diff --git a/src/Handler.php b/src/Handler.php
index 128760e..0be678b 100644
--- a/src/Handler.php
+++ b/src/Handler.php
@@ -203,6 +203,7 @@ class Handler extends BaseHandler {
       ],
       'unlighthouse' => [
         'enable' => $this->env->receiveGlobal('UNLIGHTHOUSE', 'Unlighthouse', '0'),
+        'urlprefix' => '',
       ],
     ];
   }
diff --git a/templates/docker-compose.yml.twig b/templates/docker-compose.yml.twig
index d02410e..635e43f 100644
--- a/templates/docker-compose.yml.twig
+++ b/templates/docker-compose.yml.twig
@@ -589,7 +589,7 @@ services:
       traefik.enable: 'true'
       traefik.docker.network: traefik-public
       traefik.http.services.{{ projectname }}_unlighthouse.loadbalancer.server.port: 5678
-      traefik.http.routers.unlighthouse-{{ projectname }}.rule: Host(`{{ projectdomain }}`)
+      traefik.http.routers.unlighthouse-{{ projectname }}.rule: Host(`unlighthouse-{{ projectdomain }}`)
 {% if drupal.live|default(0) or traefik.usessl %}
       traefik.http.routers.unlighthouse-{{ projectname }}.tls: 'true'
       traefik.http.routers.unlighthouse-{{ projectname }}.tls.certresolver: lakedrops
diff --git a/templates/tests/unlighthouse.config.ts b/templates/tests/unlighthouse.config.ts
deleted file mode 100644
index 4b83077..0000000
--- a/templates/tests/unlighthouse.config.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-export default {
-    puppeteerOptions: {
-        args: ["--no-sandbox"],
-    },
-    server: {
-        open: false,
-    },
-    site: "{{ projectprotocol }}://{{ projectdomain }}",
-    serverUrl: "{{ projectprotocol }}:/unlighthouse-{{ projectdomain }}/",
-    clientUrl: "{{ projectprotocol }}://unlighthouse-{{ projectdomain }}/",
-    apiUrl: "{{ projectprotocol }}://unlighthouse-{{ projectdomain }}/api",
-    websocketUrl: "{{ socketprotocol }}://unlighthouse-{{ projectdomain }}/api/ws",
-}
diff --git a/templates/tests/unlighthouse.config.ts.twig b/templates/tests/unlighthouse.config.ts.twig
new file mode 100644
index 0000000..60dbbe6
--- /dev/null
+++ b/templates/tests/unlighthouse.config.ts.twig
@@ -0,0 +1,19 @@
+export default {
+  puppeteerOptions: {
+    args: ["--no-sandbox"],
+  },
+  server: {
+    open: false,
+  },
+  site: "{{ projectprotocol }}://{{ projectdomain }}{{ unlighthouse.urlprefix|default('') }}",
+{% if basicauth.enable %}
+  auth: {
+    username: "{{ basicauth.user }}",
+    password: "{{ basicauth.pass }}",
+  },
+{% endif %}
+  serverUrl: "{{ projectprotocol }}://unlighthouse-{{ projectdomain }}/",
+  clientUrl: "{{ projectprotocol }}://unlighthouse-{{ projectdomain }}/",
+  apiUrl: "{{ projectprotocol }}://unlighthouse-{{ projectdomain }}/api",
+  websocketUrl: "{{ socketprotocol }}://unlighthouse-{{ projectdomain }}/api/ws",
+}
-- 
GitLab