Skip to main content

A quick way to deploy static websites to a fast, cheap, and reliable CDN.

Project description

trifold

A quick way to deploy static websites to a fast, cheap, and reliable CDN.

How it works

trifold is a tool to host & serve static websites with bunny.net.

It provides a simple CLI that allows:

  • initializing new projects without touching the bunny.net web interface
  • syncing local HTML/CSS/JS/etc. to the bunny.net storage & CDN
  • configuring a custom domain name to point at your files, with SSL enabled

This project grew out of my frustration with services making their free tier less friendly to indie devs & students that just need a cheap & reliable place they can host things.

Instead of relying on a free service it is hopefully going to be more stable to rely on a paid service with a reasonable price point (and the ability to set billing limits).

Like most hosts, bunny.net charges for storage & bandwidth. Storage starts at $0.01/GB/mo. bandwidth also starts at $0.01/GB/mo.

The typical static webpage is under 1GB, meaning storage costs will be negligible unless you decide to host audio/video. (And if you do, the rates are far cheaper than most competitors, see their pricing for details).

In terms of bandwidth, let's say your page size is 2MB (a moderate-sized page) and hits the front page of a popular website, driving a surge of 25,000 hits. (Congrats!)

Not only will your site handle the traffic just fine, your total bill will be $0.50 for the 50GB of bandwidth used. (You could serve a million hits (~2TB) for $20.)

Of course, most sites will only get a fraction of this traffic.

It is possible to host dozens of low-traffic sites for the bunny.net $1/monthly minimum bill.

0. Create a bunny.net account & obtain your API key

If you'd like to sign up for bunny.net with the project's affiliate link, when you pay to host your site, we'll earn a commission at no extra cost to you.

Once you have an account, visit https://dash.bunny.net/account/api-key to obtain your API key.

To use trifold you'll need to set the BUNNY_API_KEY environment variable:

$ export BUNNY_API_KEY=1234...    # replace with your key & be sure to keep it safe!

1. Initialize Project

First, your project needs a bunny.net storage & pull zone, and a local trifold.toml.

Generate one with:

$ uvx trifold init

This command will ask you a few questions:

  • storage zone name: the name of the bunny.net storage bucket, must be unique. (example: trifold-website)
  • region: primary region for file storage (default: Frankfurt, Germany)
  • replication region(s): for an additional cost per region
  • monthly bandwidth limit: avoid runaway costs by setting a bandwidth limit (default: 10GB)
  • remote path: if you'd like to serve files under a subdirectory enter the name here (example: docs)
  • local path: enter the (relative) local path to sync to the site (example: build/html)

a note about costs

Pricing starts at $0.01/GB, but additional replication or serving regions will increase this cost. See bunny.net's pricing page for details.

The default behavior is to only serve data from North America, which costs $0.01/GB in bandwidth. Other regions are available at an additional cost, and can be configured via the web interface (CDN->General->Pricing & routing).

2. Publish Your Files

With a zone created, we're ready to publish, but it's always a good idea to look before you leap-- let's check the status:

$ uvx trifold status -v

This shows us the files that will be uploaded or deleted.

As long as it shows what you're expecting, you're ready to publish:

$ uvx trifold publish

After a few seconds, your files are uploaded to the CDN.

They will be available at your-zone-name.b-cdn.net.

Whenever you want to publish changes, just repeat this step!

optional deletion

By default, for safety, this will only create or update files. If you'd like it to delete remote files that are no longer in your local directory add --delete.

This command will never modify your local files!

3. Custom Domain with SSL

If you have your own domain that you'd like to point at the hosted files, there's one more command to run:

Before you run this command, log in to your registrar and create a DNS CNAME or ALIAS record pointing your domain at your-zone-name.b-cdn.net.

Wait 5-10 minutes for DNS propagation, then:

$ uvx trifold domain-add example.com

This will configure an SSL certificate and force SSL.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trifold-0.3.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trifold-0.3.0-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file trifold-0.3.0.tar.gz.

File metadata

  • Download URL: trifold-0.3.0.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.22

File hashes

Hashes for trifold-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a7d8c97b2d5e7533dcd584bb3f0f8c88b76785ca3ffc65986348e0a8af496842
MD5 8379e0f62dce29b639c4b2fe62769dce
BLAKE2b-256 a111e2098766c3cf5b931cbeff344cf72e6e7e9a828448f1d0930554637900cc

See more details on using hashes here.

File details

Details for the file trifold-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: trifold-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.22

File hashes

Hashes for trifold-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81dfb0180df65232dc38a25b7eca211ff11c802d913daa6ede5dc05fd271a16c
MD5 52b7a434764e2eb2c99d3d784e3a7d6e
BLAKE2b-256 070a9a052f65f74ca9a457e49c12466bc8ab8d8c58a53ac12150323547e6590d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page