Mastodon Skip to main content

Installing Draw.io, Open Source Flow and Design

Diagramming is a powerful tool in the world in general. It can help you convey ideas from the very simple to the extremely complex with far less effort than to try and transmit the context of ideas and workflows with words alone.

There are literally tons of diagramming tools out there in the world, but Draw.io (a.k.a diagramming.net) is a really great, simple to setup and self host, open source diagramming tool that runs right in your browser.

Today we'll be installing the open source, self hosted version of draw.io together.

What You'll Need

  • Docker-CE
  • Docker-Compose
  • (optional) NGinX Proxy Manager
  • (optional) Portainer-CE
  • (optional) A Domain Name you own (e.g. mygreatdomain.org, etc0
  • About 10 minutes of your time.

Installing Docker-CE and Docker-Compose

If you already have Docker and Docker-Compose installed, feel free to skip down to the next section.

You can easily install Docker-CE, Docker-Compose, Portainer-CE, and NGinX Proxy manager by using this quick install script I created and maintain on Github.  Just use the command:

wget https://gitlab.com/bmcgonag/docker_installs/-/raw/main/install_docker_nproxyman.sh

To download the script to your desired host.

Change the permissios to make the script executable:

chmod +x ./install_docker_nproxyman.sh

and then run the script with the command:

./install_docker_nproxyman.sh

When run, the script will prompt you to select your host operating system, then will ask you which bits of software you want to install.

Simply enter 'y' for each thing you want to install.

At some point, you'll be asked for your super user (sudo) password as well.

Allow the script to complete installation.

At this point, you might want to log out and back in, as this will allow you to use the docker and docker-compose commands without the need of sudo in front of them.

Installing Draw.io

Now we need to create a folder structure to keep our container and it's components together, and easy to backup.

I like to create a root level "docker" folcer (and by "root level" I mean in my home direcotry.  You can create this in /opt if you like as well.  It's up to you.

mkdir docker.

Now move into that directory, and create a folder for our draw.io install.

cd docker

mkdir draw_io

Next, move into the draw_io folder, and create a new file called "docker-compose.yml".

cd draw_io

nano docker-compose.yml

Now copy the following text into that folder:

#This compose file adds diagrams.net (ex draw.io) to your stack
version: '3.5'
services:
  drawio:
    image: jgraph/drawio
    container_name: drawio
    restart: unless-stopped
    ports:
      - 8080:8080  # you can change teh left side of the colon to an open port on your host.
      - 8443:8443  # you can change teh left side of the colon to an open port on your host.
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://<your host private ip>:<your port from above> || exit 1"]
      interval: 1m30s
      timeout: 10s
      retries: 5
      start_period: 10s

Now, make sure to choose an open port for the two port mappings in the code block to open ports on your host machine.  You can change the left side of the colon ":" only, to any open port.

In my case I made them look like

8381:8080

and

12443:8443

In the line under "healthcheck:" that sasy "test:", makes ure to change the url to your host machines ip and the port mapping for 8080 from above.

So mine looks like:

http://192.168.10.141:8381

Now, save the file with CTRL + O, then press Enter to confirm, and use CTRL + X to exit the nano text editor.

Finally, we can run our docker-compose file with the command:

docker-compose up -d

This will pull down the draw.io image, and run it in the background for us.

Once it's pulled down and you see the done message, open your favorite browser, and go to your host machine's IP address on the port you set.  I went to:

http://192.168.10.141:8381

You should be greeted by the initialization screen for your own install of Draw.io.

Optional Steps: Setting up a URL for our Install

If you don't want to run your draw.io available on the open internet, you don't need to complete this stop.

Before you begin this section, you need to own a domain (for instance, I own the domain "routemehome.org").  You can use a domain you own, or you can setup something like DuckDNS for dynamic domain names. We'll be covering a regular domain.  You can register a domain with the folks over at Hover using this code to get a discount if you like, but feel free to use any domain registrar you want.

Now, we need to create an A-Record for our desired domain name.  I want to call my domain "mydraw.routemehome.org:.  I'll go to my registart's DNS settings (I can't really tell you how to do this, as every registart has this setup a little differently, but the concepts are the same no matter what).

Select to add an A-Record (create a new record and select type A).  Then enter the subdomain you want, in my case I enter "mydraw".  Next, you'll want to point that at your public IP address.  It's important to know what your public IP is.  You can use a site like http://ipchicken.com to find your public IP.  If you have a public IP from your ISP that changes regularly, you'll definitely want to consider a Dynmic DNS service like DuckDNS.  I have a video on DuckDNS here.

Now, save the record, and note that it can take anywhere from 10 minutes to 2 days for DNS to fully propogate.  Hopefully it will be closer to the 10 minutes.

Next, we need to setup the home network to get through our firewall when we try to reach our site.  We'll use a reverse proxy for this.  Hopefully you selected to install NGinX Proxy Manager on the script if you used it, but you can use any reverse proxy you like (HAProxy, Caddy, Traefik, etc).  I'll be using NGinX Proxy Manager for this tutorial.

Back to our router setup.  Again, all routers do this a bit differently, so you'll have to research a bit on how to do it on your model router, but you want to create a port forwarding rule for any traffic coming in from the internet (sometimes called the WAN) on port 80, and forward that to your NGinX Proxy Manager host's internal IP address.  Additionally, you'll want to forward any requests on port 443 to the WAN to your NGinX Proxy Manager hosts internal IP address.

Now, you are ready to setup NGinX Proxy Manager.  Create a new Proxy entry, and enter the full subdomain url for your draw.io install.   Use the same subdomain / domain you setup in your DNS settings with your domain registrar.

In my case, I used:

mydraw.routemehome.org

Next, int he IP address field, you can do several things depending on where you are running your draw.io container.

  1. If you are running it on the same machine as your NGinX Proxy Manager, you can either:

a.  Refer to it by it's container name (you can find this in Portainer-CE, or by using the docker ps command and looking at the name column).  You must have your NGinXProxy Manager and draw.io containers set to the same docker network, and this network cannot be the default network.

b. Refer to it by it's docker0 IP address.  You can find the docker0 IP with the bash command ip a show docker0.

If you use the container name, you'll use the port 8080.  If you use the docker0 IP address, you'll use the left side of the port mapping from your docker-compose file.

2. If you are running NGinX Proxy Manager on a different machine from your draw.io container, you'll use the private IP of your draw.io host machine.

I put "192.168.10.141" into the IP field, and "8381" into the port field.

At this point, you can save, and then click the entry in NGinX Proxy Manager to make sure it opens your draw.io.  NOTE: this will open it in http only mode, and will not have an SSL certificate yet.

Next, open your porxy entry in Edit mode (click the 3 dots at the right of the entry, and select 'Edit').

Now move to the SSL tab.  Select "Request a New Certificate", tick the "Force SSL" option, enter your email, and accept the TOS for LetsEnctrypt.  

Click Save, and wait for the pop-up to close, it may take a minute so be patient.  If you get an error before it closes, you may need to check through all of your setup, then try again.

If it closes with no issues, you should now be ablel to browse to your site, and have SSL encrtyped access to your Draw.io install.

Support my Channel and Content

Support my Channel and ongoing efforts through Patreon:
https://www.patreon.com/bePatron?u=234177