diff --git a/docker/README.md b/docker/README.md index ecc5462c1..7ecfb499b 100644 --- a/docker/README.md +++ b/docker/README.md @@ -106,8 +106,10 @@ You can specify the following environment variables when issuing `docker run` co | `AWS_REGION` | string | | AWS Region when using `s3` media handler | | `AWS_S3_BUCKET` | string | | Name of the AWS S3 bucket when using `s3` media handler | | `AWS_SECRET_ACCESS_KEY` | string | | AWS [Secret Access Key](https://aws.amazon.com/blogs/security/wheres-my-secret-access-key/) when using `s3` media handler | +| `CLUSTER_SELF` | string | | Node name if the server is running in a Tinode cluster | | `DEBUG_EMAIL_VERIFICATION_CODE` | string | | Enable dummy email verification code, e.g. `123456`. Disabled by default (empty string). | | `EXT_CONFIG` | string | | Path to external config file to use instead of the built-in one. If this parameter is used all other variables except `RESET_DB`, `FCM_SENDER_ID`, `FCM_VAPID_KEY` are ignored. | +| `EXT_STATIC_DIR` | string | | Path to external directory containing static data (e.g. Tinode Webapp files) | | `FCM_CRED_FILE` | string | | Path to json file with FCM server-side service account credentials which will be used to send push notifications. | | `FCM_SENDER_ID` | string | | FCM sender ID for receiving push notifications in the web client | | `FCM_VAPID_KEY` | string | | Also called 'Web Client certificate' in the FCM console. Required by the web client to receive push notifications. | diff --git a/docker/tinode/entrypoint.sh b/docker/tinode/entrypoint.sh index e0456ac40..dafe2e7fa 100644 --- a/docker/tinode/entrypoint.sh +++ b/docker/tinode/entrypoint.sh @@ -41,6 +41,14 @@ else done < config.template fi +# If external static dir is defined, use it. +# Otherwise, fall back to "./static". +if [ ! -z "$EXT_STATIC_DIR" ] ; then + STATIC_DIR=$EXT_STATIC_DIR +else + STATIC_DIR="./static" +fi + # Load default sample data when generating or resetting the database. if [[ -z "$SAMPLE_DATA" && "$UPGRADE_DB" = "false" ]] ; then SAMPLE_DATA="$DEFAULT_SAMPLE_DATA" @@ -48,11 +56,11 @@ fi # If push notifications are enabled, generate client-side firebase config file. if [ ! -z "$FCM_PUSH_ENABLED" ] ; then - # Write client config to static/firebase-init.js - echo "const FIREBASE_INIT={messagingSenderId: \"$FCM_SENDER_ID\", messagingVapidKey: \"$FCM_VAPID_KEY\"};"$'\n' > static/firebase-init.js + # Write client config to $STATIC_DIR/firebase-init.js + echo "const FIREBASE_INIT={messagingSenderId: \"$FCM_SENDER_ID\", messagingVapidKey: \"$FCM_VAPID_KEY\"};"$'\n' > $STATIC_DIR/firebase-init.js else # Create an empty firebase-init.js - echo "" > static/firebase-init.js + echo "" > $STATIC_DIR/firebase-init.js fi # Initialize the database if it has not been initialized yet or if data reset/upgrade has been requested. @@ -68,5 +76,11 @@ if [ -s /botdata/tino-password ] ; then ./credentials.sh /botdata/.tn-cookie < /botdata/tino-password fi +args=("--config=${CONFIG}" "--static_data=$STATIC_DIR" "2>&1") + +# Maybe set node name in the cluster. +if [ ! -z "$CLUSTER_SELF" ] ; then + args+=("--cluster_self=$CLUSTER_SELF") +fi # Run the tinode server. -./tinode --config=${CONFIG} --static_data=static 2>&1 +./tinode "${args[@]}"