Run Database in GitHub Actions, Persisting Data to S3, and Access it Publicly

submited by
Style Pass
2024-12-12 08:00:04

When it comes to running a database for development, testing, demos, or short-lived workloads, cost and complexity can be big headaches. Traditional database hosting—like a VPS, a cloud VM, or a managed service—comes with ongoing costs, storage expenses, and configuration overhead. You often end up paying for resources even when you're not using them.

But what if you could just "borrow" some compute for free whenever you need it, spin up a database, store data cheaply (or even at zero cost), and shut it all down when you're done—without losing any data? Sounds too good to be true, but we can actually do this using GitHub Actions as our ephemeral compute environment and S3 (or an S3-compatible service) as our persistent storage. With this combo plus a simple tunneling trick, we get a MySQL-compatible database available to anyone on the internet, running only when needed, at zero cost.

Tip: Want to make it entirely free? Instead of using AWS S3, consider an S3-compatible service like Cloudflare R2, which has a generous free tier. That way, both your compute (GitHub Actions) and storage (R2) can be leveraged at essentially no cost.

Leave a Comment