Skip to main content
This guide outlines the process of deploying Permify, on Fly.io. We will be using Fly’s deploy with a Dockerfile functionality.

Pre-reqs: Install flyctl

Before we begin, we need to make sure to have the flyctl command-line utility installed. Install instructions can be found here.

Running with Postgres for persistent storage

1. Create a database on Fly

Let’s create a semi-managed instance of Postgresql on Fly to store our data so that everything isn’t lost when the machines scale down to 0. Run the command fly postgres create, give the new fly app a name, select its location and machine setup. For this example the development configuration was used, but you can choose to make yours highly available with the other options.
Keep username and password in a secure location like a secrets manager. We’ll need the connection string as well in order to connect to our database.

2. Create a simple Dockerfile or use the base image directly

Due to limitations with the flyctl command of fly deploy, we can’t alter the entrypoint or run command from fly deploy so we need to directly create our fly machines To create them directly we can use a Dockerfile which we’ll simplify to a single line:

3. Create a new Fly App and configure the services

Create a new fly app with the fly launch command and edit the fly.toml file that gets created:

4. Deploy to fly

With the configuration setup, we can now deploy our container to fly Run the command in the directory with our Dockerfile and fly.toml configuration:

Running Permify on Fly without a database

1. Create a simple project within a directory

We’re going to setup a simple git repository to store our configuration for Fly.io and a simple Dockerfile to deploy.

2. Create a Dockerfile

Let’s create a Dockerfile that uses the latest container image from the Github Registry. We’ll set it up to just run the command serve in order to run the container without any additional configuration.

3. Setup the fly configuration

Next step is to configure our app to run on Fly. Run the command fly launch to get an initial configuration setup and generate a basic fly.toml file. You can tweak the default configurations to change Region, App Machines, Memory, etc.

4. Edit the Fly configuration to expose our ports and service

We’ll need to tweak the default configuration generated for us by the flyctl command fly launch to get our app working. We’ll remove the generated section [http_service] and add two [[services]] sections to our configuration. This is so we can expose both the REST API and gRPC ports of 3476 and 3478. If you only want to expose one or the other, then keep only the port service that you wish to expose.

5. Deploy your fly app

Now we can deploy our service to Fly by using the command fly deploy. Once it’s done building and the status is showing as deployed, you can check the url provided by Fly to your app in your web browser if the REST API port was exposed by checking the health endpoint https://<your-app-url>:3476/healthz and you should see {"status":"SERVING"}.

Example repository

Example configurations for this can be found https://github.com/theoriginalstove/permify-fly-deploy-example