Title: Deploy to Fly.io Tags: [deployment]
- Python >= 3.8
- A Fly.io account
Install the Fly CLI to deploy apps using command lines.
For macOS:
brew install flyctlFor other operating systems, follow the installation guide.
Sign up and log in to Fly.
flyctl auth signup
flyctl auth loginTest 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-deploymentRun your app:
chainlit run app.pyCreate 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.
Set up a payment method on Fly.io (no charge for the free plan).
Then, create your Fly project:
flyctl launchAnswer "No" to all prompts during setup.
Deploy your app:
flyctl deployAfter deployment, set the app instance count to 1:
flyctl scale count 1This 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.
- 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.