Visitar URL original
cookbook/fly-io-deployment at main · Chainlit/cookbook · GitHub
Skip to content

Latest commit

 

History

History

fly-io-deployment

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Title: Deploy to Fly.io Tags: [deployment]

Tutorial repo for deploying to Fly.io

Quickstart

Prerequisites

  • Python >= 3.8
  • A Fly.io account

Step 1: Install the Fly CLI

Install the Fly CLI to deploy apps using command lines.

For macOS:

brew install flyctl

For other operating systems, follow the installation guide.

Step 2: Login to Fly

Sign up and log in to Fly.

flyctl auth signup
flyctl auth login

Step 3: Run Chainlit App Locally

Test your app locally before deploying.

Clone the example if needed:

git clone https://github.com/Chainlit/cookbook.git chainlit-cookbook
cd chainlit-cookbook/fly-io-deployment

Run your app:

chainlit run app.py

Step 4: Prepare Procfile and requirements.txt

Create a Procfile with the command to start your app:

web: python -m chainlit run app.py -h --port 8080

Ensure you have a requirements.txt listing all Python dependencies.

Step 5: Create Fly Project

Set up a payment method on Fly.io (no charge for the free plan).

Then, create your Fly project:

flyctl launch

Answer "No" to all prompts during setup.

Step 6: Deploy

Deploy your app:

flyctl deploy

After deployment, set the app instance count to 1:

flyctl scale count 1

This is necessary because Fly.io doesn't support sticky WebSocket sessions by default.

Visit your app at the provided hostname from the flyctl launch output.

Additional Notes

  • If you require features like autoscaling and sticky sessions, consider deploying on AWS ECS or GCP with a load balancer that supports these features.
  • For detailed deployment steps and troubleshooting, refer to the blog post and check the deployed example app.

App running