Last active
September 4, 2024 07:17
-
-
Save csaroff/69524877f16716f18381429abf9653ab to your computer and use it in GitHub Desktop.
A script to deploy ollama to fly.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Variables | |
APP_NAME="<name>" # Replace <name> with your desired app name | |
VOLUME_NAME="ollama" | |
IMAGE_NAME="ollama/ollama" | |
INTERNAL_PORT=11434 | |
VM_SIZE="shared-cpu-8x" | |
MOUNT_POINT="/mnt/ollama/models" | |
ENV_VARIABLES="OLLAMA_MODELS=$MOUNT_POINT" | |
# Step 1: Login to Fly.io | |
echo "Logging in to Fly.io..." | |
fly auth login | |
# Step 2: Create a new Fly app | |
echo "Launching new Fly app: $APP_NAME..." | |
fly launch --name "$APP_NAME" --image "$IMAGE_NAME" --internal-port "$INTERNAL_PORT" --vm-size "$VM_SIZE" --now | |
# Step 3: Pull and run orca-mini:3b | |
echo "Running model: orca-mini:3b..." | |
export OLLAMA_HOST="https://$APP_NAME.fly.dev" | |
ollama run orca-mini:3b | |
# Optional: Set up persistent volume | |
echo "Creating persistent volume..." | |
fly volume create "$VOLUME_NAME" | |
# Update fly.toml for mounts | |
echo "Updating fly.toml for mounts..." | |
{ | |
echo "[mounts]" | |
echo " source = \"$VOLUME_NAME\"" | |
echo " destination = \"$MOUNT_POINT\"" | |
} >> fly.toml | |
# Update fly.toml for environment variables | |
echo "Updating fly.toml for environment variables..." | |
{ | |
echo "[env]" | |
echo " $ENV_VARIABLES" | |
} >> fly.toml | |
# Deploy the app with updates | |
echo "Deploying app with persistent volume configuration..." | |
fly deploy | |
echo "Deployment completed. Your app is now live at https://$APP_NAME.fly.dev." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment