Skip to content

Commit

Permalink
Removed the obsolete real-time info and variables
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohamedin committed Sep 22, 2023
1 parent b1bb82e commit 75dd012
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 70 deletions.
13 changes: 1 addition & 12 deletions main/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,7 @@ echo "window.DRAW_MATH_URL = 'math/es5';" >> $CATALINA_HOME/webapps/draw/js/PreC
#Custom draw.io configurations. For more details, https://www.drawio.com/doc/faq/configure-diagram-editor
echo "window.DRAWIO_CONFIG = ${DRAWIO_CONFIG:-null};" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js
#Real-time configuration
if [[ "${DRAWIO_IOT_ENDPOINT}" ]]; then
echo "urlParams['sync'] = 'auto'; //Enable Real-Time" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js
echo "window.MXPUSHER_IOT_ENDPOINNT = '${DRAWIO_MXPUSHER_ENDPOINT}'; //Specifies the IoT endpoint" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js
echo "window.DRAWIO_PUSHER_MODE = 2;" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js
mkdir -p $CATALINA_HOME/webapps/draw/WEB-INF/aws_iot_auth
echo -n "${DRAWIO_IOT_CERT_PEM}" > $CATALINA_HOME/webapps/draw/WEB-INF/aws_iot_auth/mxPusherSrv.cert.pem
echo -n "${DRAWIO_IOT_PRIVATE_KEY}" > $CATALINA_HOME/webapps/draw/WEB-INF/aws_iot_auth/mxPusherSrv.private.key
echo -n "${DRAWIO_IOT_ROOT_CA}" > $CATALINA_HOME/webapps/draw/WEB-INF/aws_iot_auth/root-CA.crt
echo -n "${DRAWIO_IOT_ENDPOINT}" > $CATALINA_HOME/webapps/draw/WEB-INF/aws_iot_auth/endpoint_url
else
echo "urlParams['sync'] = 'manual'; //Disable Real-Time" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js
fi
echo "urlParams['sync'] = 'manual'; //Disable Real-Time" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js

#Disable unsupported services
echo "urlParams['db'] = '0'; //dropbox" >> $CATALINA_HOME/webapps/draw/js/PreConfig.js
Expand Down
51 changes: 1 addition & 50 deletions self-contained/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,58 +51,9 @@ This service is currently used by VSDX importer for converting EMF files in VSDX

This service is based on [Cloud Convert](http://cloudconvert.com). You will need to register for an account and set the environment variable `DRAWIO_CLOUD_CONVERT_APIKEY` to the API KEY. We use API **V1** API KEY.

## Real-time Collaboration

draw.io supports real-time collaboration with Google Drive and Microsoft OneDrive. In order to enable this feature, you need to a real-time notification service (we support [pusher.com](https://pusher.com/) and [AWS IoT](https://aws.amazon.com/iot-core/?nc=sn&loc=2&dn=3)). This docker compose file is set to use AWS IoT.
You need to follow the instructions in `etc/mxPusher` folder to setup a lambda function for temporary keys as well as setting a role for that lambda function.

Then, you need to create a `Thing` in AWS IoT core console (e.g, `mxPusher`). Next, from "Secure", select "Certificates", then "Create". Download the certificate ".cert.pem" file, the private and public key files, and root CA (we tested with "Amazon Root CA 1"). Finally, click "Activate" and click "Attach a policy". In the "Add authorization to certificate" page that will open, click "Create new policy" button, give it a name and click "Advanced mode". Copy and paste the following JSON.

```JSON
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iot:Connect",
"iot:Subscribe",
"iot:Publish",
"iot:Receive"
],
"Resource": "*"
}
]
}
```
Finally, you will need to attach the "Thing" to this certificate. Select "Actions", menu in "Certificates" -> "Attach thing" and select the thing you just created.

Now set the following environment variables:

* `DRAWIO_CACHE_DOMAIN`: Your deployment domain (e.g, `drawio.example.com`)
* `DRAWIO_IOT_ENDPOINT`: From the AWS IoT Core, select the "Thing" you created, then "Interact". Set this variable to the listed HTTPS endpoint.
* `DRAWIO_IOT_CERT_PEM`: The content of the certificate file downloaded above.
* `DRAWIO_IOT_PRIVATE_KEY`: The content of the private key file downloaded above.
* `DRAWIO_IOT_ROOT_CA`: The content of the root certificate file downloaded above.
* `DRAWIO_MXPUSHER_ENDPOINT`: The temporary keys Lambda function URL (from `etc/mxPusher` folder)

If you want to deploy to multiple servers/nodes. Then, a central cache is needed. We support memcached.

* `DRAWIO_MEMCACHED_ENDPOINT`: Your memcached server instance url and port (e.g, `10.0.0.111:11211`)

# AWS Deployment

You can deploy this docker compose easily to AWS ECS. Follow the instructions in this [tutorial](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-cli-tutorial-ec2.html) to install Amazonn ECS CLI, create a cluster, and deploy "self-contained" docker compose file to it. We recommend EC2 deployment as it is easy to connect with Amazon ElastiCache if you plan to use real-time collaboration.
You can deploy this docker compose easily to AWS ECS. Follow the instructions in this [tutorial](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-cli-tutorial-ec2.html) to install Amazonn ECS CLI, create a cluster, and deploy "self-contained" docker compose file to it. We recommend EC2 deployment.
You will need to chnage port mapping to 80 and 443 to support standard HTTP and HTTPS ports in `docker-compose.yml`. Don't forget to allow access to these ports in the security group inbound rules. Also, it is required to set `DRAWIO_BASE_URL` environment variable in order to have a fully functional deployment. Set the other environment variables as described above to enable other services and features as needed.

Refer to the main [README](https://github.com/jgraph/docker-drawio) file for how to configure **Let's Encrypt**.

If you are not planning to use Amazon ElastiCache memcached, remove the `DRAWIO_MEMCACHED_ENDPOINT` line from the docker compose file.

## Amazon ElastiCache

It is strongly recommended to use Amazon ElastiCache memcached (or similar memcached service) to support multiple nodes in the cluster.
Navigate to AWS ElastiCache dashboard, create a cluster (Memcached) with all standard settings except for "Node type" which can be as small as "cache.t2.micro". Then, in "Advanced Memcached settings", select "Create new" in the "Subnet group" field and select VPC used in your ECS. Also, you can select all subnets in that VPC. Then, ensure that the selected security group allow inbound access to memcached port (e.g, 11211). You can select the same security group as ECS and allow inbound access to memcached port 11211 only from this cache cluster.
Finally, set the environment variable `DRAWIO_MEMCACHED_ENDPOINT` to the cluster "Configuration Endpoint"

**Note**: Currently, the real-time features are available in `jgraph/drawio-expr` image only and not yet available in `jgraph/drawio`.
8 changes: 0 additions & 8 deletions self-contained/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ services:
- DRAWIO_GITLAB_SECRET=${DRAWIO_GITLAB_SECRET}
- DRAWIO_GITLAB_URL=${DRAWIO_GITLAB_URL}
- DRAWIO_CLOUD_CONVERT_APIKEY=${DRAWIO_CLOUD_CONVERT_APIKEY}
- DRAWIO_CACHE_DOMAIN=${DRAWIO_CACHE_DOMAIN}
- DRAWIO_MEMCACHED_ENDPOINT=${DRAWIO_MEMCACHED_ENDPOINT}
- DRAWIO_PUSHER_MODE=2
- DRAWIO_IOT_ENDPOINT=${DRAWIO_IOT_ENDPOINT}
- DRAWIO_IOT_CERT_PEM=${DRAWIO_IOT_CERT_PEM}
- DRAWIO_IOT_PRIVATE_KEY=${DRAWIO_IOT_PRIVATE_KEY}
- DRAWIO_IOT_ROOT_CA=${DRAWIO_IOT_ROOT_CA}
- DRAWIO_MXPUSHER_ENDPOINT=${DRAWIO_MXPUSHER_ENDPOINT}
networks:
drawionet:

Expand Down

1 comment on commit 75dd012

@davidjgraph
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed.

Please sign in to comment.