agent_backend / DEPLOY.md
GoutamSachdev's picture
ok
de6fb09 verified
|
Raw
History Blame Contribute Delete
2.17 kB
# Deploying to Fly.io
This backend service uses `Docker` and `uv` for easy deployment. Since it uses SQLite for data persistence, we need to configure a persistent volume on Fly.io.
## Prerequisites
1. Install `flyctl` (Fly.io CLI).
2. Login: `fly auth login`.
## Deployment Steps
### 1. Initialize the App
Run the launch command in this directory (`backend/`):
```bash
fly launch
```
- **Choose a unique app name** (e.g., `my-chatkit-backend`).
- **Select a region** (choose one close to you).
- **Would you like to set up a Postgresql database now?** -> **No** (we use SQLite).
- **Would you like to set up an Upstash Redis database now?** -> **No**.
- **Do you want to deploy now?** -> **No** (we need to set secrets first).
This creates a `fly.toml` file.
### 2. Set Up Data Persistence (Volumes)
Since the app uses SQLite (`chatkit_threads.db` and `user_state.db`), you need a persistent volume so data isn't lost when the app restarts.
Create a 1GB volume (adjust size if needed):
```bash
fly volumes create chatkit_data --size 1 --region <your-region>
```
*Make sure to use the same region you selected in step 1.*
### 3. Update `fly.toml`
Open `fly.toml` and add the `[mounts]` section to mount the volume to `/data` in the container. Also add the environment variables to tell the app to use that path.
Add this to `fly.toml`:
```toml
[mounts]
source = "chatkit_data"
destination = "/data"
[env]
CHATKIT_DB_PATH = "/data/chatkit_threads.db"
USER_STATE_DB_PATH = "/data/user_state.db"
PORT = "8000"
```
### 4. Set Secrets
Set your API keys using `fly secrets`. Copy values from your `.env.local`:
```bash
fly secrets set \
GROQ_API_KEY=your_groq_key \
OPENAI_API_KEY=your_openai_key \
OPENROUTER_API_KEY=your_openrouter_key \
DEEPSEEK_API_KEY=your_deepseek_key \
GOOGLE_API_KEY=your_google_key \
CARTESIA_API=your_cartesia_key
```
### 5. Deploy
Now you are ready to deploy:
```bash
fly deploy
```
## Verifying Deployment
Check the logs to ensure everything started correctly:
```bash
fly logs
```
Your app should now be running!