Skip to content

Commit

Permalink
Allow specifying cluster id and static dir in docker container.
Browse files Browse the repository at this point in the history
Specify:
* CLUSTER_SELF for tinode node id (in cluster mode)
* EXT_STATIC_DIR for static data.
  • Loading branch information
aforge committed Oct 1, 2019
1 parent 959ec6b commit 377c69a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
22 changes: 18 additions & 4 deletions docker/tinode/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,26 @@ 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"
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.
Expand All @@ -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[@]}"

0 comments on commit 377c69a

Please sign in to comment.