changeset 4195:22cd3094cd1e

docker (demo): fix starting + better UX: - Use the new `wait_for_service` option to be sure that Prosody is launched. - Use the new `init_script_path` option to initiate forums and bookmark a demo room. - Activate MUC service. - Change log formats to make them more readable.
author Goffi <goffi@goffi.org>
date Wed, 13 Dec 2023 22:00:25 +0100
parents 3dbaf179c50d
children 8b673bb307c1
files docker/backend-dev-demo/Dockerfile docker/backend-dev-demo/forums.json docker/backend-dev-demo/libervia.conf docker/backend-dev-demo/scripts/init_script.sh docker/backend-dev/libervia.conf docker/prosody-e2e/prosody.cfg.lua
diffstat 6 files changed, 67 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/docker/backend-dev-demo/Dockerfile	Wed Dec 13 22:00:25 2023 +0100
+++ b/docker/backend-dev-demo/Dockerfile	Wed Dec 13 22:00:25 2023 +0100
@@ -22,10 +22,11 @@
 RUN ./entrypoint.sh \
     # and a demo account
     libervia-cli profile create demo -j demo@server1.test -p "demo"  && \
-    # we create a bookmark to have something to test in chat
-    libervia-cli bookmarks add -pdemo -a demo@server1.test\
     libervia-backend stop
 
+COPY --chown=libervia:libervia forums.json /home/libervia/
+COPY --chown=libervia:libervia scripts/init_script.sh /home/libervia/
+
 USER libervia
 # HTTP Upload
 EXPOSE 7777
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/backend-dev-demo/forums.json	Wed Dec 13 22:00:25 2023 +0100
@@ -0,0 +1,38 @@
+[
+    {
+        "main-language": "en",
+        "name": "Libervia",
+        "title": "Libervia",
+        "short-desc": "Forums about Libervia demo",
+        "sub-forums": [
+            {
+                "uri": "",
+                "title": "tools and features",
+                "short-desc": "Discussions about Libervia frontends, tools, features, or changes"
+            },
+            {
+                "uri": "",
+                "title": "questions and help",
+                "short-desc": "Mutual assistance for installation or using Libervia and its ecosystem"
+            }
+        ],
+        "desc": "Those are example forums."
+    },
+    {
+        "main-language": "en",
+        "title": "XMPP and associated",
+        "sub-forums": [
+            {
+                "uri": "",
+                "title": "XMPP software",
+                "short-desc": "Topics about XMPP software other than Libervia"
+            },
+            {
+                "uri": "",
+                "title": "outside XMPP",
+                "short-desc": "You can discuss or present here protocols or software similar to XMPP"
+            }
+        ],
+        "desc": "Forums about XMPP in general, or similar protocols"
+    }
+]
--- a/docker/backend-dev-demo/libervia.conf	Wed Dec 13 22:00:25 2023 +0100
+++ b/docker/backend-dev-demo/libervia.conf	Wed Dec 13 22:00:25 2023 +0100
@@ -1,4 +1,7 @@
 [DEFAULT]
+log_fmt = [%%(name)s] %%(message)s
+init_wait_for_service=prosody:5222::Prosody
+init_script_path=/home/libervia/init_script.sh
 xmpp_domain = server1.test
 email_server = libervia-backend.test
 email_port = 8025
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/backend-dev-demo/scripts/init_script.sh	Wed Dec 13 22:00:25 2023 +0100
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+SETUP_INDICATOR="/home/libervia/.local/share/libervia/setup_complete.flag"
+FORUMS_JSON_FILE="/home/libervia/forums.json"
+
+if [ ! -f "$SETUP_INDICATOR" ]; then
+    echo "First run detected. Setting up the environment and configuration."
+
+    libervia-cli profile modify -D -cp demo --pwd demo
+    libervia-cli forums set -p demo < $FORUMS_JSON_FILE
+    libervia-cli bookmarks add -pdemo -a demo@chat.server1.test
+
+    touch "$SETUP_INDICATOR"
+    echo "Initial setup complete."
+else
+    echo "Not the first run. Skipping setup."
+fi
--- a/docker/backend-dev/libervia.conf	Wed Dec 13 22:00:25 2023 +0100
+++ b/docker/backend-dev/libervia.conf	Wed Dec 13 22:00:25 2023 +0100
@@ -1,2 +1,3 @@
 [DEFAULT]
+log_fmt = [%%(name)s] %%(message)s
 media_dir = /src/libervia-media
--- a/docker/prosody-e2e/prosody.cfg.lua	Wed Dec 13 22:00:25 2023 +0100
+++ b/docker/prosody-e2e/prosody.cfg.lua	Wed Dec 13 22:00:25 2023 +0100
@@ -109,11 +109,11 @@
 
 VirtualHost "server3.test"
 
--- Component "muc.server1.test" "muc"
--- 	modules_enabled = {
--- 		"muc_mam";
--- 		"vcard";
--- 	}
+Component "chat.server1.test" "muc"
+ 	modules_enabled = {
+ 		"muc_mam";
+ 		"vcard";
+ 	}
 
 Component "pubsub.server1.test"
 	component_secret = "test_e2e"