Appearance
Launch π β
This guide walks you through deploying the AuthCompanion server on Fly.io, from initial setup to production-ready configuration. You'll use a container image (from the Dockerfile) and configure your application with a fly.toml
file. Let's get started!
1. Prerequisites β
- Install Flyctl:
Follow Fly.io's install instructions. - Sign up for Fly.io:
Requires a credit card, but you can use the free tier.
2. Project Setup β
Clone and Enter the Project Directory
bashgit clone https://github.com/authcompanion/authcompanion2.git cd authcompanion2/
Initialize the Fly App
bashflyctl launch
- Say No to setting up a Postgres database.
- Say No to deploying now (you'll configure first).
3. fly.toml Configuration β
Fly.io uses fly.toml
to describe your deployment. After flyctl launch
, edit the file as follows:
Mandatory Environment Variables β
In the [env]
section of fly.toml
, set these (replace with your app's values):
toml
[env]
# Public URL for authentication (required for passkeys)
ORIGIN = "https://<your-app>.fly.dev"
# Where users are redirected after login/register
APPLICATION_ORIGIN = "https://<your-app>.fly.dev/home"
# AuthCompanion Admin dashboard (optional; set for user management)
ADMIN_ORIGIN = "http://demo.authcompanion.com/admin/dashboard"
Set the Internal Port β
In the [[services]]
section:
toml
[[services]]
internal_port = 3002
# ...rest unchanged...
Example fly.toml Snippet β
toml
app = "<your-app-name>"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[env]
ORIGIN = "https://<your-app>.fly.dev"
APPLICATION_ORIGIN = "https://<your-app>.fly.dev/home"
ADMIN_ORIGIN = "http://demo.authcompanion.com/admin/dashboard"
[[services]]
internal_port = 3002
# ...rest of your service config...
4. Deploy to Fly.io β
bash
flyctl deploy
- After deployment, visit:
https://<your-app>.fly.dev/login
- Replace
<your-app>
with the value in yourfly.toml
- Replace
5. Configure a Custom Domain (Optional) β
Get your appβs IPs:
bashflyctl ips list -a <your-app>
Update DNS:
AddA
andAAAA
records for your domain (e.g.,auth.example.com
) pointing to the IPs from above.Provision a TLS Certificate:
bashflyctl certs add auth.example.com -a <your-app> flyctl certs show auth.example.com -a <your-app>
Update Environment Variables in
fly.toml
:toml[env] ORIGIN = "https://auth.example.com" APPLICATION_ORIGIN = "https://auth.example.com/home" # ...other env vars...
Redeploy:
bashflyctl deploy
Now, visit:
https://auth.example.com
6. Persistent Storage β
AuthCompanion stores users in a SQLite database file. To persist data across restarts:
Create a Volume:
bashfly volumes create authc_userdata --region <region> --size 1 --no-encryption
- Find your region code: Fly.io Regions
Add to
fly.toml
:toml[[mounts]] source = "authc_userdata" destination = "/data"
Update
[env]
for persistent paths:toml[env] SERVER_KEY_PATH = "/data/keyfile" SQLITE_DB_PATH = "/data/authcompanion_users.db" # ...other env vars...
Redeploy:
bashflyctl deploy
7. Outbound Email (Account Recovery) β
To enable password recovery (and similar features), configure SMTP settings:
Set Email Environment Variables in
fly.toml
:toml[env] RECOVERY_REDIRECT_URL = "https://auth.example.com/profile" SMTP_HOSTNAME = "smtp.migadu.com" SMTP_PORT = 465 SMTP_USERNAME = "<your-username>" SMTP_PASSWORD = "$SMTP_PASSWORD" FROM_ADDRESS = "<your-email>"
Set SMTP Password as a Secret:
bashflyctl secrets set SMTP_PASSWORD=<yourpassword>
Redeploy:
bashflyctl deploy
8. Example fly.toml
(from the AuthCompanion Demo) β
See the demo fly.toml for a full reference:
toml
app = "demo-authcompanion"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[env]
ORIGIN="https://demo.authcompanion.com"
APPLICATION_ORIGIN="https://demo.authcompanion.com/home"
SERVER_KEY_PATH="/data/serverkeyv5"
ADMIN_KEY_PATH="/data/adminkeyv5"
SQLITE_DB_PATH="/data/sqlite_authc_databasev5.db"
RECOVERY_REDIRECT_URL="https://demo.authcompanion.com/profile"
SMTP_HOSTNAME="smtp.migadu.com"
SMTP_PORT=465
SMTP_USERNAME="hello@authcompanion.com"
SMTP_PASSWORD="$SMTP_PASSWORD"
FROM_ADDRESS="hello@authcompanion.com"
[[services]]
internal_port = 3002
# ...rest unchanged...
[[mounts]]
source = "authc_userdata"
destination = "/data"
9. Troubleshooting & Further Help β
- If you run into issues, see Getting Help.
- For more configuration examples, check the official fly.toml.
Youβre all set!
Enjoy a secure, scalable AuthCompanion deployment on Fly.io.