• Deployments
  • Fly.io

Deploy Authorizer on Fly.io


This guide explains how to deploy a ready-to-use Authorizer instance on Fly.io.

Fly.io is a platform for running full stack apps and databases close to your users.

Fly.io also provide custom domain configuration and free SSL using Let's Encrypt via the CLI.


To follow along, you need to complete the steps below:

  • A Fly account. If you don't have one, you can visit the link above and click on "Sign In" in the top right corner to log in either with your GitHub or email.

  • Fly CLI

Deploy an Authorizer Instance

Deploy production ready Authorizer instance using fly.io with Postgres and Redis for free.

Step 1: Login to Fly.io

flyctl auth login

Step 2: Create Fly.io app

Create new empty directory and move to this directory:

mkdir authorizer-fly
cd authorizer-fly

Create new Fly.io app instance:

flyctl launch --no-deploy

Follow the wizard to set the application name, region, etc. You will find new file named fly.toml.

Authorizer at Fly.io

Step 3: Setup Postgres instance

Fly.io provide free tier Postgres with limited resource. Consider to use larger Posgres instance when using at production. Read more details about Postgres at Fly here.

flyctl postgres create --password <YOUR_SECURE_DATABASE_PASSWORD>

Follow the wizard just like previous command. You will be given the option to provide a name, location, and configuration. Choose Development configuration to use free instance of Postgres.

Authorizer at Fly.io

To connecting the Postgres database with the app, we need to attach by using this command:

flyctl postgres attach <POSTGRES_APP_NAME>

Step 4: Setup Redis instance

To spin up a Redis instance, please follow this official documentation.

Step 5: Configure fly.toml file

Add this part to fly.toml file:

image = "lakhansamani/authorizer:latest"
cmd = ["./build/server", "--database_type=postgres"]
private_network = true
auto_rollback = true
  PORT = "8080"

Change internal_port to 8080 inside the [[services]] section just like this:

  internal_port = 8080

This is a complete example fly.toml file (don't forget to change the app value):

app = "authorizer"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
image = "lakhansamani/authorizer:latest"
cmd = ["./build/server", "--database_type=postgres"]
private_network = true
auto_rollback = true
  PORT = "8080"
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
    type = "connections"
    hard_limit = 25
    soft_limit = 20
    force_https = true
    handlers = ["http"]
    port = 80
    handlers = ["tls", "http"]
    port = 443
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

Step 6: Configure Authorizer Environment

flyctl secrets set \
    ENV="production" \
    DATABASE_TYPE="postgres" \
    SMTP_PORT=587 \

Don't forget to replace the values.

Refer to Environment Variables section to see all variables.

Step 7: Deploy

Finally, deploy the app by execute this command:

flyctl deploy

After the deployment process has been finish, check the application logs:

flyctl logs

That's all 🎉 you can start integrating Authorizer in your frontend application.

Update Instance

Since we using lakhansamani/authorizer:latest Docker image, to updating Authorizer on Fly.io is easy. You only need to redeploy the app using flyctl deploy command inside the directory containing fly.toml configuration file.

Custom Domain and SSL

Fly.io provide custom domain configuration and free SSL using Let's Encrypt via the CLI. To setup custom domain, please refer to this documentation.

Last updated on March 31, 2023