I’ve been trying to stand up my own instance(s) of Jitsi Meet, but found it very painful to manually stand up the infrasructure.
After doing all the steps I mentioned here I stopped the containers and took a snapshot, so I could avoid having to redo all the configuration.
I also set up DNS records (managed outside of Digital Ocean) to point at a fixed IP address (“Floating IP”, inside Digital Ocean); this IP address can then be attached to any instance I spin up.
The manual work
Once I’d done this, I still had to do all the following by hand:
- Create the droplet from a snapshot
- Attach the droplet to the firewall(s)
- Attach the floating IP address to the droplet
- Log in to the instance & run
docker-compose up -d
This was slow, repetative, and boring, so I had a go at making (via lots searching/reading documentation/copy-pasting/trial&error) a Terraform script to do it for me; its below!
Now I just run one line to bring the server up:
terraform apply -var="do_token=xxxxxxx" # If I don't want an approval prompt, # I can add "-auto-approve" to the end
And then one line to tear it down:
terraform destroy -var="do_token=xxxxxxx" # If I don't want an approval prompt, # I can add "-auto-approve" to the end
There’s a bunch of stuff I could do better:
- It feels wrong having my DNS records point permanently at this fixed IP address that I then dynamically attach to my droplets. Ideally the DNS record itself would be pointed directly at each instance I created, and have a short TTL to react to droplets being created/destroyed. I couldn’t script this, as my DNS isn’t managed within Digital Ocean (or any Terraform-compatible space).
- Having the multiline
user_datascript directly in the Terraform script looks really messy - but for a toy project like this I’d rather just worry about a single uglier file than multiple “better” files.
- I’ve hardcoded a (quite big) instance size. This is because the original snapshot was taken on a box this big, and you can’t boot up a droplet from a snapshot that was taken on a bigger instance.
- I’m probably going to recreate the snapshot on a much smaller droplet so I can deploy using small droplets too.
- I could store my Digital Ocean token in a configuration file instead of pasting it in from my password manager.
Real world use & costs
It was a fun project, which I’m finding real usecases for now! When I’m going to have a group video chat with family or friends, I run the
terraform one-liner above, and the whole thing is ready within 2 minutes!
I test ran this on a droplet with 6 vCPUs & 16GB RAM for a call with 5 people and the server barely broke a sweat (neither CPU nor RAM usage went above 10%). We had the server up for about 5 hours, for a total cost of $0.60!