Host on AWS EC2
A worked example of running a Tusile community server on a cloud VM, using AWS EC2. Only the CLI commands are AWS-specific: the sizing, ports and setup steps apply to any VPS. The install itself is the one in the install guide; this page covers what a cloud host has to decide on top of it.
Pick a size
Section titled “Pick a size”The stack is five containers: Postgres, LiveKit, Caddy, the community server and a small cert-sync sidecar. Memory is the binding constraint, not CPU.
| Instance | Memory | Verdict |
|---|---|---|
t3.small |
2 GB | Comfortable. Use this for anything real. |
t3.micro |
1 GB | Works, and is free-tier eligible. Add swap. |
t3.nano |
0.5 GB | Runs only with swap, and the OOM killer takes Postgres first if you skip it. Fine for a test, not for members. |
Give the root volume at least 12 GB. The five images plus Amazon Linux plus a 2 GB swapfile do not fit comfortably in the 8 GB default.
Create the security group
Section titled “Create the security group”Open the ports from the install guide’s port table, plus SSH locked to your own address (not 0.0.0.0/0):
SG=$(aws ec2 create-security-group --group-name tusile-community \ --description "Tusile community server" --vpc-id <your-default-vpc> \ --query GroupId --output text)
aws ec2 authorize-security-group-ingress --group-id "$SG" --ip-permissions \ 'IpProtocol=tcp,FromPort=22,ToPort=22,IpRanges=[{CidrIp=YOUR.IP.HERE/32}]' \ 'IpProtocol=tcp,FromPort=80,ToPort=80,IpRanges=[{CidrIp=0.0.0.0/0}]' \ 'IpProtocol=tcp,FromPort=443,ToPort=443,IpRanges=[{CidrIp=0.0.0.0/0}]' \ 'IpProtocol=tcp,FromPort=7880,ToPort=7881,IpRanges=[{CidrIp=0.0.0.0/0}]' \ 'IpProtocol=tcp,FromPort=5349,ToPort=5349,IpRanges=[{CidrIp=0.0.0.0/0}]' \ 'IpProtocol=udp,FromPort=3478,ToPort=3478,IpRanges=[{CidrIp=0.0.0.0/0}]' \ 'IpProtocol=udp,FromPort=50000,ToPort=50060,IpRanges=[{CidrIp=0.0.0.0/0}]'Launch with Docker preinstalled
Section titled “Launch with Docker preinstalled”Amazon Linux 2023 has docker in its repositories but not the Compose plugin, so that one is fetched directly. Save this as userdata.sh:
#!/bin/bashset -euxexec > /var/log/tusile-bootstrap.log 2>&1
# Swap. Skip only on 2 GB or more.dd if=/dev/zero of=/swapfile bs=1M count=2048chmod 600 /swapfilemkswap /swapfileswapon /swapfileecho '/swapfile none swap sw 0 0' >> /etc/fstab
dnf install -y dockersystemctl enable --now dockerusermod -aG docker ec2-user
# Compose plugin is not in the AL2023 repos.mkdir -p /usr/libexec/docker/cli-pluginscurl -sSL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64 \ -o /usr/libexec/docker/cli-plugins/docker-composechmod +x /usr/libexec/docker/cli-plugins/docker-compose
touch /var/lib/tusile-bootstrap-doneThen launch. Resolve the current Amazon Linux 2023 x86_64 AMI rather than pasting an ID that will be stale in a month:
AMI=$(aws ec2 describe-images --owners amazon \ --filters "Name=name,Values=al2023-ami-2023.*-kernel-6.1-x86_64" "Name=state,Values=available" \ --query 'reverse(sort_by(Images,&CreationDate))[0].ImageId' --output text)
aws ec2 run-instances \ --image-id "$AMI" --instance-type t3.small \ --key-name YOUR-KEYPAIR --security-group-ids "$SG" --subnet-id <a-public-subnet> \ --block-device-mappings 'DeviceName=/dev/xvda,Ebs={VolumeSize=12,VolumeType=gp3}' \ --user-data file://userdata.sh \ --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=tusile-community}]'Wait for /var/lib/tusile-bootstrap-done to appear on the instance before you continue, rather than guessing.
Point DNS at it first
Section titled “Point DNS at it first”Do this before running setup. Caddy asks Let’s Encrypt for a certificate during the install, and that fails until the name resolves to the instance. Create an A record for your domain pointing at the instance’s public IP, then confirm from the instance itself:
getent ahostsv4 chat.example.com # must print the instance's public IPcurl -s https://api.ipify.org # the same addressOffgrid servers can skip this and use the bare IP, but then Let’s Encrypt cannot issue and the server falls back to its own certificate authority: desktop and mobile ask you to confirm the fingerprint once, and the web app cannot connect at all.
Install, unattended
Section titled “Install, unattended”Copy the bundle up and run setup with flags, so nothing waits for a keypress:
scp -i key.pem -r community-server ec2-user@YOUR.IP:/home/ec2-user/ssh -i key.pem ec2-user@YOUR.IP
cd community-server && chmod +x setup.sh
# Cloud: Tusile accounts. Create the server in the app first for the token../setup.sh --cloud --token YOUR_TOKEN --hostname chat.example.com --yes
# Offgrid: standalone, local usernames and passwords, no tusile.com contact../setup.sh --offgrid --hostname chat.example.com --yesCheck the exit code: 0 means the stack is up. The other codes, and every flag, are in Unattended install. An Offgrid install prints a one-time owner claim token at the end; Connect from the app explains how to use it, or read it again if you lose it.
Voice comes up a few minutes after text on a first run, while LiveKit waits for its TURN certificate. That is normal; see First run takes a few minutes.
Verify
Section titled “Verify”curl https://chat.example.com/healthreturns{"status":"ok"}, with a valid certificate.- Offgrid:
curl https://chat.example.com/inforeports"offgrid": true. docker compose psshows five containers, none inRestarting.- Join from the Tusile app and test text and voice in one channel.
Tear it down
Section titled “Tear it down”Terminating the instance deletes its root volume only if DeleteOnTermination was set, which is the default for the root device. The security group and key pair survive termination and have to go separately.
aws ec2 terminate-instances --instance-ids i-xxxxxxxxaws ec2 wait instance-terminated --instance-ids i-xxxxxxxxaws ec2 delete-security-group --group-id "$SG" # only after the network interface is goneaws ec2 delete-key-pair --key-name YOUR-KEYPAIR
aws ec2 describe-volumes --filters Name=status,Values=available # should be emptyaws ec2 describe-addresses # release any unattached Elastic IPAn unattached Elastic IP is billed by the hour. Check for one even if you think you never allocated it.