# Automata

> A small self-hosted PaaS that deploys Docker apps from a Git repo, with Cloudflare Tunnel routing and R2 backups.

- **Year**: 2026
- **Platforms**: web
- **Tools**: [Rust](https://wastu.net/experiments/automata/tools/rust), [Docker Compose](https://docs.docker.com/compose/), [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/), [Cloudflare Access](https://developers.cloudflare.com/cloudflare-one/policies/access/), [Cloudflare R2](https://developers.cloudflare.com/r2/), [SQLite](https://sqlite.org)
- **Links**: [GitHub](https://github.com/bgwastu/automata), [Open the demo](https://automata-demo.wastu.workers.dev)

# The problem

I've tried most of the self-hosted PaaS options. [CapRover](https://caprover.com), then [Dokku](https://dokku.com), then [Easypanel](https://easypanel.io), then [Coolify](https://coolify.io). They all work, but none of them felt right to me.

I like infrastructure as code. I want my server setup in a Git repo, so I can read it, review it, and roll it back. These tools kept pulling me back to clicking around in a dashboard.

Kubernetes can do all of that, but it's way too much for my side projects. I just wanted something small.

So I built Automata. It runs on my server and deploys whatever is in my Git repo. Cloudflare handles routing, logins, and backups, so I don't have to.

![Automata on a Linux server pulls from a GitHub repo and syncs Cloudflare DNS, Access, Tunnel, and R2 through the API](/content/architecture-light-c30bfd07.webp#dark=/content/architecture-dark-29583a64.webp "Not my finest drawing, but the arrows point the right way.")

# One repo, one folder per app

My infra repo has a folder for each app. Each folder has an `automata.yml`, plus a Compose file, a Dockerfile, or just an image.

```yaml
# apps/whoami/automata.yml
image: traefik/whoami:latest
routes:
  - host: whoami.example.com
    service: app
    port: 80
```

That's the whole app. I push it, and about 30 seconds later it's live with HTTPS. If I delete the folder, the app stops, but its volumes stay.

The dashboard is read-only. Git is the only place where changes happen.

# No open ports, no certbot

This is my favorite part.

Normally, putting an app online means opening ports 80 and 443, running a reverse proxy, and keeping certbot happy. I didn't want to deal with any of that.

With [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/), the server connects out to Cloudflare, and requests come back through that connection. So no inbound ports, no reverse proxy, and no certificates on the server. Cloudflare handles TLS.

![Comparison of the usual setup with open ports, a reverse proxy, and certbot against Automata, where requests pass through Cloudflare edge TLS, Access, and Tunnel to a cloudflared container](/content/request-light-fc0d0d17.webp#dark=/content/request-dark-c5162bd1.webp "The usual setup, and the Cloudflare one.")

Automata runs `cloudflared` as a container next to the apps. On every sync, it writes the tunnel routes and creates the DNS records. Remove a route from Git, and its DNS record goes too.

[Cloudflare Access](https://developers.cloudflare.com/cloudflare-one/policies/access/) gives me SSO for free. I use it for admin panels and anything I don't want public. It's a few lines on the route:

```yaml
routes:
  - host: app.example.com
    service: web
    port: 3000
    access:
      policy: staff
      protect: ["/"]
      public_paths: ["/api", "/api/*"]
```

Automata sets up Access before the route goes live. If it can't confirm the login is in place, the route stays private.

# The sync loop

Every 30 seconds, Automata checks the repo and syncs everything.

![The sync loop. Automata reads the branch head, downloads the commit, applies Access, syncs tunnel routes and DNS, and deploys changed apps. If the containers stay up the deployment is recorded, otherwise the previous one is kept or restored](/content/sync-light-030357f7.webp#dark=/content/sync-dark-767d3dab.webp "One pass of the sync loop.")

- **No `git clone`.** It downloads the exact commit as a tarball from the GitHub API. Nothing to get dirty on the server.
- **Deploys wait for health.** It runs `docker compose up --build --wait`, then watches the containers for a bit. If one crashes or turns unhealthy, the deploy fails.
- **Failed deploys roll back.** The last good deployment comes back, and every deployment records the commit and images it came from.
- **Secrets live in Git.** I encrypt them with `automata encrypt` and commit them. The server decrypts them at deploy time.

# Backups to R2

Volumes are the only thing I can't rebuild from Git, so they go to [Cloudflare R2](https://developers.cloudflare.com/r2/) every night. Turning it on is `backup: {}`.

![The backup flow. At 03:00 Automata pauses the app or runs a dump hook, archives the volumes, and uploads them to daily, weekly, and monthly folders in R2](/content/backup-flow-light-ab933daa.webp#dark=/content/backup-flow-dark-988f92be.webp "Nightly backups, sorted into daily, weekly, and monthly.")

By default, it pauses the app while it copies. For databases, it can run something like `pg_dump` first instead.

R2 lifecycle rules handle cleanup. By default, I keep 7 daily, 4 weekly, and 6 monthly backups. There's also a test restore, so I can check a backup actually works.

# The rest

- **Cron jobs** live in the same `automata.yml`.
- **Monitoring** for the host and each app, with deploys marked on the charts.
- **Self-updates**, but only if the release is signed.

You can click around the [demo](https://automata-demo.wastu.workers.dev). It's the real dashboard with sample data.

# Out of my comfort zone

This is my first Rust project, and I built it with AI.

Honestly, it was scary. Vibing with a language I don't fully understand meant I couldn't always tell if the code was good or if it just compiled.

But I'm glad I did it. The experiment turned out to be quite a success.

#### Why I used Rust in Automata

Automata is my first project in Rust. It ships as a single binary that runs on the server as a systemd service and talks to Docker directly.
