Deploy
PostOwl is a SvelteKit application inspired by editable.website using SQLite for the database. It’s currently optimised for SvelteKit’s adapter-node to enable deployment to Fly.io.
More deployment options coming soon!
We’ll be adding instructions for deploying to other hosts soon. If you have success deploying to other platforms, please let us know or submit a PR documenting how you did it.
Sending email in production
PostOwl uses nodemailer to send email notifications when you send letters to friends.
The application will run without a real SMTP server configured so you can enter dummy data for the SMTP settings when deploying if you don’t need to send emails.
If you’d like to send emails but don’t have an SMTP server to use, we recommend mailgun. Their free tier will cover usage for a personal PostOwl site. You’ll need to own a domain name to get set up with mailgun. Follow their documentation to activate your domain for email sending. Then generate an SMTP password from their admin interface (click ‘Reset password’ under Sending > Domain Settings > SMTP credentials to get a password for a new domain).
Deployment to fly.io
PostOwl runs for free on fly.io which is one of the reasons we’re recommending their platform for the first release. If you follow the steps here you should have a live site in about 15 minutes.
The PostOwl repository contains the files you need to deploy your PostOwl site to fly.io.
- Create an account with fly.io.
- Add your credit card to Fly. PostOwl runs well on Fly’s free tier but they require an active, valid credit / bank card to prevent abuse. Unless you have a very busy site, hosting will be free.
- Install
flyctl
and sign in withfly auth login
- Clone the PostOwl code to a directory on your computer:
git clone https://github.com/PostOwl/postowl.git
- Enter the directory you cloned the repo to:
cd postowl
- Rename
.env.production.example
to.env.production
- Edit
.env.production
:- Don’t change the value of
DB_PATH
- Edit all values with
your
in them (make sure to set a secure password) - For the SMTP details, see the section above Sending email in production. You don’t need to use real values to try the app.
- Don’t change the value of
- Run
fly launch
and respond to the prompts:- Choose a name for your app (e.g.
yourapp
- app names need to be unique across all of fly.io) or hit enter to let Fly auto-generate a name - Choose a Fly organization to deploy to if prompted
- Select the region to deploy to (Fly will automatically select one close to you)
- Choose a name for your app (e.g.
- Edit the generated
Dockerfile
, replaceRUN npm run build
withRUN mkdir /data && npm run build
- Edit the generated
fly.toml
file. After the[build]
section paste the lines below:
[experimental]
cmd = ["/app/scripts/start-fly.sh"]
entrypoint = ["sh"]
- Run
fly deploy
Fly will let you know when the app is deployed. Visit the URL shown in your terminal and sign in with the ADMIN_PASSWORD
you set in .env.production
.
Have fun creating letters! 🦉
‘Scale to zero’ on fly.io
‘Scale to zero’ means that when your site is inactive, the machine will automatically shutdown. This saves costs and electricity. For low traffic personal sites it’s ideal.
In the past, the problem with shutting down is that it would take some time for your site to start up again - remember the Heroku free plan?! Fly.io use firecracker vms which start almost instantly. If your site goes to sleep, you’ll hardly notice it starting up. In our tests it takes about one second for the server to respond to an http request from a cold start! 🔥
The default configuration in PostOwl has auto_stop_machines = true
in fly.toml.example
. We recommend you keep this setting. We have code that gracefully closes the database connection and shuts down the application server before the machine stops.
Now you can have the benefits of a dynamic web application without the costs of keeping a VPS up all the time. And you’re being kind to the environment! 🌳
Connect a domain to your Fly.io app
You can serve PostOwl from a domain or subdomain you own.
- Run
fly ips list -a myapp
to get the IPv4 and IPv6 addresses. - Head over to your DNS provider and add A and AAAA records for myapp.com with the IPv4 and IPv6 values.
- Run
fly certs create -a myapp myapp.com
- Run
fly certs show -a myapp myapp.com
to watch your certificates being issued.
More details and considerations for subdomains in the fly docs