Deploying CrewAI for a New Client

πŸ“Œ Overview

This section outlines the steps required to deploy the CrewAI setup for a new client, including domain configuration, company-specific settings, and private registry deployment. Additionally, it includes automated deployment scripts to streamline the process.


1️⃣ Preparing for Deployment

πŸ“Œ Steps to Take Before Deployment

  1. Ensure Client's Server is Ready
    • Verify they have a compatible cloud provider (AWS, GCP, DigitalOcean, Vultr, etc.)
    • If using on-premises, confirm Linux (Ubuntu 22.04+) is installed
    • Ensure sufficient resources (CPU, RAM, storage, network bandwidth)
  2. Provision a New Server
    • Deploy a VM or containerized environment
    • Open necessary firewall ports (80, 443 for web, 8000 for API)

Install Docker & Docker Compose:

curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
newgrp docker
sudo apt install docker-compose -y

2️⃣ Automated Deployment Script

To automate the deployment process, create the following script and execute it on the client’s server.

πŸ“Œ Create deploy_crewai.sh

#!/bin/bash

# Variables (Replace these values for each client)
REGISTRY_URL="myregistry.com"
IMAGE_NAME="crewai-template:latest"
DOMAIN_NAME="api.clientcorp.com"
SECRET_KEY=$(openssl rand -hex 32)

# Update and install dependencies
echo "Updating system and installing dependencies..."
sudo apt update && sudo apt upgrade -y
sudo apt install -y nginx certbot python3-certbot-nginx

# Install Docker & Docker Compose
echo "Installing Docker and Docker Compose..."
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
newgrp docker
sudo apt install -y docker-compose

# Pull and Run CrewAI Container
echo "Logging into Docker registry and pulling CrewAI image..."
docker login $REGISTRY_URL

echo "Deploying CrewAI container..."
docker run -d --name crewai-api \
  -p 8000:8000 \
  -e CREWAI_ENV=production \
  -e SECRET_KEY=$SECRET_KEY \
  -v /data/logs:/app/logs \
  $REGISTRY_URL/$IMAGE_NAME

# Create NGINX config
echo "Setting up NGINX..."
cat <<EOT | sudo tee /etc/nginx/sites-available/crewai-client
server {
    listen 80;
    server_name $DOMAIN_NAME;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host \$host;
        proxy_set_header X-Real-IP \$remote_addr;
    }
}
EOT

sudo ln -s /etc/nginx/sites-available/crewai-client /etc/nginx/sites-enabled/
sudo systemctl restart nginx

# Secure with Let's Encrypt SSL
echo "Setting up SSL with Certbot..."
sudo certbot --nginx -d $DOMAIN_NAME --non-interactive --agree-tos -m admin@$DOMAIN_NAME

# Verify deployment
echo "Verifying deployment..."
curl -X GET https://$DOMAIN_NAME/health-check

echo "Deployment complete! CrewAI is now running on $DOMAIN_NAME"

πŸ“Œ Running the Deployment Script

  1. Upload deploy_crewai.sh to the new client’s server

Run the script:

./deploy_crewai.sh

Give execution permission:

chmod +x deploy_crewai.sh

βœ… Now, the deployment is fully automated!


3️⃣ Finalizing Deployment & Testing

πŸ“Œ Verify the Deployment

curl -X GET https://api.clientcorp.com/health-check

Expected Response:

{"status": "ok"}

βœ… Now, the API is live and functional.

πŸ“Œ Monitor Logs for Issues

docker logs -f crewai-api

βœ… Now, logs can be monitored for troubleshooting.


πŸ“Œ Summary of Steps for Deploying CrewAI to a New Client

Step Action
Provision Server Setup VM, install Docker & dependencies.
Run Automated Script Execute deploy_crewai.sh to deploy API.
Configure Client Settings Modify .env file for company details.
Setup Reverse Proxy Configure NGINX for domain forwarding.
Enable SSL Secure API with Let's Encrypt SSL.
Verify Deployment Check API status and logs.

βœ… Now, CrewAI is fully deployed for the new client with automation!