All projects

Internal tool · Swan Web

Swan Deploy

A command-line tool I built to get Swan Web websites live, with hosting, domains and sign-in email set up together.

My role
Designed and built the deployment tool
Development
AI-assisted development
Tools
TypeScript, Docker, Coolify, Cloudflare, Resend

Backstory

When we hosted our websites on Hostinger, putting a new version online meant logging in and uploading the files by hand. I built a CLI that let me pick a website and upload a folder straight from my terminal over SFTP.

By the time I’d built Swan Editor, our websites shared a common setup and we hosted them on our own VPS running Coolify. Getting a website live could still take me an hour or two. I’d connect the right GitHub repository in Coolify, create a personal access token for that repository and add it to the website’s environment variables.

Swan Editor used that token to save a client’s edits back to GitHub. Each update triggered Coolify to rebuild and redeploy the website so the change went live.

I also had to connect the client’s domain and get the sign-in emails working. The details changed from client to client, but the setup was much the same. I put those details in a config file and built Swan Deploy to handle the repeated steps.

Preparing the website

The swan.yml file describes where the code is, which branch to deploy, the client’s domain and the type of website. I supply the GitHub token and other credentials separately.

For a Swan Editor website, swan prepare generates the Docker files, the Compose configuration that describes which services run together, and the scripts that start them. I review the generated files, commit them and push the changes to the client’s repository.

Loading video…
Generating the Docker and startup files for a sample Swan Editor website.

Previewing the changes

I built swan plan so I could see what the deploy command would do before running it. It compares the config with what’s already set up and gives me a read-only list of the changes it would make.

Loading video…
Reviewing the planned hosting, DNS and sign-in email setup before deploying.

Running the deployment

The demo uses the guarded test-deployment mode for an Editor website. Before setting anything up, Swan Deploy checks that I’ve committed the prepared files and that the revision I reviewed is the one on GitHub.

  • In Coolify, Swan Deploy connects the repository and sets up the application with the GitHub token and its other environment variables. Once those settings are in place, it enables automatic redeploys and starts the first build.
  • In Cloudflare, it points the website domain at the server and adds the DNS records required for sign-in email.
  • In Resend, it sets up and verifies the sending domain so Swan Editor can send one-time codes from the client’s own domain.

The config controls which services get set up. A static website only needs hosting and DNS. An Editor website also needs MongoDB for sign-in and content indexing, and can use Cloudflare R2 for uploaded media. The ecommerce setup adds the Medusa backend and its PostgreSQL database.

Loading video…
A staged run setting up Coolify, Cloudflare DNS and Resend before starting the build.

Checking it was live

After Coolify finishes building, Swan Deploy checks that it built the revision I reviewed and that the website responds over HTTPS on the public domain. DNS and certificates can take a while to catch up, so I made the tool remember what it had already set up. If a deployment times out, I can rerun the command and pick up with the resources it already created.

From there I open the public website on the client’s domain, then check I can sign in to Swan Editor and save a change.

Loading video…
Opening the public website, then checking an edit in the sample admin panel.