From e20c2b8cd820356a3a3b8e1370910d234a69adf6 Mon Sep 17 00:00:00 2001
From: Quentin Duchemin <quentinduchemin@tuta.io>
Date: Wed, 11 Dec 2019 15:03:55 +0100
Subject: [PATCH] Fix JSON settings syntax ; fix mysql healthcheck ; add
 healthcheck

---
 pica-etherpad/Dockerfile    |  5 ++-
 pica-etherpad/entrypoint.sh |  2 +-
 pica-etherpad/settings.json | 86 ++++++++++++-------------------------
 3 files changed, 32 insertions(+), 61 deletions(-)

diff --git a/pica-etherpad/Dockerfile b/pica-etherpad/Dockerfile
index 974a1548..f2ccd0d6 100644
--- a/pica-etherpad/Dockerfile
+++ b/pica-etherpad/Dockerfile
@@ -65,9 +65,10 @@ RUN useradd --uid ${UID} --create-home etherpad
 
 # Import des fichiers téléchargés dans l'image downloader
 COPY --from=downloader --chown=etherpad /opt/etherpad-lite /opt/etherpad-lite/
-
+EXPOSE 8080
+HEALTHCHECK CMD curl --fail http://localhost:8080 || exit 1
 WORKDIR /opt/etherpad-lite/
 USER etherpad
-EXPOSE 8080
+
 ENTRYPOINT ["/opt/etherpad-lite/entrypoint.sh"]
 CMD [ "/bin/bash", "-c", "/opt/etherpad-lite/bin/run.sh" ]
diff --git a/pica-etherpad/entrypoint.sh b/pica-etherpad/entrypoint.sh
index 1c7db59a..b8f4d416 100644
--- a/pica-etherpad/entrypoint.sh
+++ b/pica-etherpad/entrypoint.sh
@@ -22,7 +22,7 @@ if [ -z "{ETHERPAD_DB_HOST}" ]; then
 	exit 1
 fi
 
-while ! mysqladmin ping -h"$ETHERPAD_DB_HOST"; do
+while ! mysqladmin ping -u${ETHERPAD_DB_USER} -p${ETHERPAD_DB_PASSWORD} -h"$ETHERPAD_DB_HOST"; do
     sleep 1
 done
 
diff --git a/pica-etherpad/settings.json b/pica-etherpad/settings.json
index c89d9126..1bfa21f2 100644
--- a/pica-etherpad/settings.json
+++ b/pica-etherpad/settings.json
@@ -1,34 +1,3 @@
-/*
- * This file must be valid JSON. But comments are allowed
- *
- * Please edit settings.json, not settings.json.template
- *
- * Please note that starting from Etherpad 1.6.0 you can store DB credentials in
- * a separate file (credentials.json).
- *
- *
- * ENVIRONMENT VARIABLE SUBSTITUTION
- * =================================
- *
- * All the configuration values can be read from environment variables using the
- * syntax "${ENV_VAR}" or "${ENV_VAR:default_value}".
- *
- * This is useful, for example, when running in a Docker container.
- *
- * EXAMPLE:
- *    "port":     "${PORT:9001}"
- *    "minify":   "${MINIFY}"
- *    "skinName": "${SKIN_NAME:colibris}"
- *
- * Would read the configuration values for those items from the environment
- * variables PORT, MINIFY and SKIN_NAME.
- *
- * If PORT and SKIN_NAME variables were not defined, the default values 9001 and
- * "colibris" would be used.
- * The configuration value "minify", on the other hand, does not have a
- * designated default value. Thus, if the environment variable MINIFY were
- * undefined, "minify" would be null.
- */
 {
   "title": "${ETHERPAD_TITLE:Picapad}",
   "favicon": "${FAVICON:favicon.ico}",
@@ -43,9 +12,8 @@
     "database": "${ETHERPAD_DB_NAME}",
     "user":     "${ETHERPAD_DB_USER}",
     "password": "${ETHERPAD_DB_PASSWORD}",
-    "charset":  "utf8mb4",
+    "charset":  "utf8mb4"
   },
-
   "defaultPadText": "Bienvenue sur Picapad, une instance d'Etherpad, un éditeur de texte collaboratif libre.\n-----------------------------------------------------------\nLe texte que vous saisissez est automatiquement synchronisé avec toutes les personnes naviguant sur ce pad.\n\nPrenez des notes et rédigez des documents librement !\n\n→ Pour bien commencer :\n• Renseignez votre nom ou pseudo, en cliquant sur l’icône « utilisateur » en haut à droite.\n• Choisissez votre couleur d'écriture au même endroit.\n• Les contributions de chacun se synchronisent « en temps réel » sous leur propre couleur.\n• Un chat vous permet de discuter avec les autres personnes présentes sur le pad.\n\n→ Fonctionnalités :\n• Couleur du texte, tableau, choix et taille de police, alignement, pleine page...\n• Sauvegarde automatique du pad.\n• Historique complet du pad (bouton en forme d'horloge)\n• Sauvegarde de versions clés (bouton en forme d'étoile).\n• Commentaires avec suggestion de remplacement (bouton en forme de bulle).\n• Les réglages vous permettent de désactiver les couleurs, de changer la langue, d'activer les sauts de pages...\n\n→ Partage :\n• Import et export dans divers formats (bouton avec les flèches).\n• Partage en lecture seule, pour éviter les modifications non voulues (bouton </>).\n\nPensez à garder l'URL de votre pad pour le retrouver.\nAttention, celui-ci est public, c'est-à-dire que toute personne qui en possède l'URL pourra y accéder :n'y stockez pas d'informations confidentielles !\n-----------------------------------------------------------\nUne question ? Un problème ? Envoyez-nous un mail à picasoft@assos.utc.fr !",
   "padOptions": {
     "noColors":         false,
@@ -61,27 +29,27 @@
     "lang":             "fr"
   },
 
-  "padShortcutEnabled" : {
-    "altF9":     true, /* focus on the File Menu and/or editbar */
-    "altC":      true, /* focus on the Chat window */
-    "cmdShift2": true, /* shows a gritter popup showing a line author */
+  "padShortcutEnabled": {
+    "altF9":     true,
+    "altC":      true,
+    "cmdShift2": true,
     "delete":    true,
     "return":    true,
-    "esc":       true, /* in mozilla versions 14-19 avoid reconnecting pad */
-    "cmdS":      true, /* save a revision */
-    "tab":       true, /* indent */
-    "cmdZ":      true, /* undo/redo */
-    "cmdY":      true, /* redo */
-    "cmdI":      true, /* italic */
-    "cmdB":      true, /* bold */
-    "cmdU":      true, /* underline */
-    "cmd5":      true, /* strike through */
-    "cmdShiftL": true, /* unordered list */
-    "cmdShiftN": true, /* ordered list */
-    "cmdShift1": true, /* ordered list */
-    "cmdShiftC": true, /* clear authorship */
-    "cmdH":      true, /* backspace */
-    "ctrlHome":  true, /* scroll to top of pad */
+    "esc":       true,
+    "cmdS":      true,
+    "tab":       true,
+    "cmdZ":      true,
+    "cmdY":      true,
+    "cmdI":      true,
+    "cmdB":      true,
+    "cmdU":      true,
+    "cmd5":      true,
+    "cmdShiftL": true,
+    "cmdShiftN": true,
+    "cmdShift1": true,
+    "cmdShiftC": true,
+    "cmdH":      true,
+    "ctrlHome":  true,
     "pageUp":    true,
     "pageDown":  true
   },
@@ -153,12 +121,14 @@
           "recipients": "picasoft@assos.utc.fr",
           "sendInterval": 3000,
           "transport": "SMTP",
-          "host": "mail.picasoft.net",
-          "port": 465,
-          "secureConnection": true,
-          "auth": {
-              "user": "${ETHERPAD_MAIL_USER}",
-              "pass": "${ETHERPAD_MAIL_PASSWORD}"
+          "SMTP": {
+            "host": "mail.picasoft.net",
+            "port": 465,
+            "secureConnection": true,
+            "auth": {
+                "user": "${ETHERPAD_MAIL_USER}",
+                "pass": "${ETHERPAD_MAIL_PASSWORD}"
+            }
           }
         }
       }
-- 
GitLab