Clojure Stack TemplatesClojure Stack Templates

Fly.io

Deploy your Clojure application with Fly.io

Deploying to Fly.io from Local Machine

If you have created your application using the option :deploy :none, you can deploy it to Fly.io by following these steps:

Add flyctl System Dependency

Add flyctl to the .mise.toml file with the latest version available (or install it manually):

.mise.toml
[tools]
...
flyctl = "0.3.112"
 
[alias]
...

Then run mise install.

Create a New Fly.io Configuration

Run the following commands to create a new Fly.io configuration:

flyctl auth login
flyctl launch --no-deploy

This command will create a fly.toml file in the root of your project. You can edit it to set the desired configuration.

SQLite

If you are using SQLite, you need to add a volume to the fly.toml file:

fly.toml
...
[mounts]
  source = "your-unique-volume-name"
  destination = "/app/db"
  initial_size = 1

PostgreSQL

For PostgreSQL, you have several options:

  • Use Managed PostgreSQL from Fly.io.
  • Run PostgreSQL as a regular service on Fly.io.
  • Use any other managed PostgreSQL service, such as Neon or Supabase.

Deploy Your Application

Run the following command to deploy your application:

flyctl deploy

Deploying to Fly.io from GitHub Actions

Generate Access Token

Generate a new access token in your Fly.io account settings and add it to your repository secrets as FLY_API_TOKEN.

Add the following .github/workflows/deploy.yml file:

.github/workflows/deploy.yml
name: Deploy
 
on:
  push:
    branches: [ master ]
 
jobs:
  checks:
    uses: ./.github/workflows/checks.yaml
 
  deploy:
    runs-on: ubuntu-latest
    timeout-minutes: 20
    needs: [ checks ]
    steps:
      - uses: actions/checkout@v4
      - uses: jdx/mise-action@v2
        with:
          install_args: "flyctl"
 
      - name: Build and Deploy
        env:
          FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
        run: flyctl deploy --remote-only

Deploy Your Application from GitHub Actions

Push your changes to the master branch to trigger the deployment automatically.

On this page