This document provides comprehensive deployment instructions for the Movie Chatbot application, with a focus on Cloud Foundry deployment options with the Tanzu Platform.
- Deployment Prerequisites
- Deployment Options
- CI/CD Integration
- GenAI Service Integration
- Database Service Integration
- High Availability Configuration
- Custom Domain Configuration
- Scaling Considerations
- Common Issues & Troubleshooting
- Deployment Checklist
- Additional Documentation
Before deploying the application, ensure you have:
- Cloud Foundry CLI installed (
cfcommand available) - Access to a Tanzu Platform for Cloud Foundry environment
- Access to the GenAI tile in your foundation
- Proper permissions to create and bind services
- The application code from the repository
Additional requirements:
- API keys for external services if not using bound services:
- TMDB API key (required)
- SerpAPI key (optional, for theater showtimes)
- Understanding of your organization's network policies
- Knowledge of resource constraints in your environment
-
Login to your Cloud Foundry instance:
cf login -a API_ENDPOINT -o YOUR_ORG -s YOUR_SPACE
-
Review and modify the
manifest.ymlfile if needed:applications: - name: movie-chatbot memory: 512M disk_quota: 1G instances: 1 buildpacks: - python_buildpack command: gunicorn movie_chatbot.wsgi --log-file - env: PYTHONUNBUFFERED: true DISABLE_COLLECTSTATIC: 1 DEBUG: false LOG_LEVEL: info
-
Build static assets locally:
cd frontend npm run build cd .. python manage.py collectstatic --noinput
-
Push the application:
cf push --no-start
-
Configure environment variables and services (see sections below)
-
Start the application:
cf start movie-chatbot
The vendor approach pre-packages the essential dependencies for deployment, which can be useful in environments with limited internet access during staging.
1.a Run the deployment script:
./deploy-on-tp4cf.shThis script will:
- Set up the vendor directory with dependencies
- Collect static files
- Stage the app artifact on Cloud Foundry
1.b. If you prefer to run the steps manually:
# Set up the vendor directory
./setup-vendor.sh
# Deploy to Cloud Foundry
cf push --no-start-
Configure environment variables and services (see sections below)
-
Start the application:
cf start movie-chatbot
The application includes CI/CD configurations for multiple platforms to automate building, testing, and deploying the application. These configurations handle both backend (Python/Django) and frontend (React) components.
The GitHub Actions workflow (.github/workflows/py-django-crewai.yml) automates:
- Backend testing with Django test framework
- Frontend building with Node.js and npm
- Static file collection
- Package creation
- Artifact upload
The workflow is triggered on pushes and pull requests that affect the py-django-crewai project files.
For deployment via GitHub Actions, use the on-demand Cloud Foundry deployment workflow described in the repository's main DEPLOY.md.
The GitLab CI configuration (ci/gitlab/.gitlab-ci.yml) provides:
- Backend testing
- Frontend building
- Static file collection
- Package creation
- Optional Cloud Foundry deployment
The pipeline is organized into stages: install, test, build, package, and deploy.
To enable automatic deployment, set the following CI/CD variables in GitLab:
CF_API: Cloud Foundry API endpointCF_USERNAME: Cloud Foundry usernameCF_PASSWORD: Cloud Foundry passwordCF_ORG: Cloud Foundry organizationCF_SPACE: Cloud Foundry spaceCF_DEPLOY: Set to "true" to enable deployment
The Jenkins pipeline (ci/jenkins/Jenkinsfile) includes:
- Backend testing
- Frontend building
- Static file collection
- Package creation
- Optional Cloud Foundry deployment
The pipeline uses Jenkins' built-in caching mechanisms to speed up builds.
To enable automatic deployment, set the following environment variables in Jenkins:
CF_API: Cloud Foundry API endpoint (as a Jenkins credential)CF_USERNAME: Cloud Foundry username (as a Jenkins credential)CF_PASSWORD: Cloud Foundry password (as a Jenkins credential)CF_ORG: Cloud Foundry organization (as a Jenkins credential)CF_SPACE: Cloud Foundry space (as a Jenkins credential)CF_DEPLOY: Set to "true" to enable deployment
The Bitbucket Pipelines configuration (ci/bitbucket/bitbucket-pipelines.yml) provides:
- Backend testing
- Frontend building
- Static file collection
- Package creation
- Artifact upload
- Manual Cloud Foundry deployment
The pipeline uses parallel steps to speed up the build process.
To enable deployment, set the following repository variables in Bitbucket:
CF_API: Cloud Foundry API endpointCF_USERNAME: Cloud Foundry usernameCF_PASSWORD: Cloud Foundry passwordCF_ORG: Cloud Foundry organizationCF_SPACE: Cloud Foundry space
The application is designed to work with the GenAI tile, which provides LLM capabilities.
-
Check available service plans:
cf marketplace -e genai
-
Create a service instance:
cf create-service genai PLAN_NAME movie-chatbot-llm
Where
PLAN_NAMEis one of the available service plans. -
Check the service creation status:
cf service movie-chatbot-llm
-
Bind the service to your application:
cf bind-service movie-chatbot movie-chatbot-llm
-
Restage the application to apply the binding:
cf restage movie-chatbot
-
Verify the binding:
cf env movie-chatbot
Look for the
VCAP_SERVICESsection in the output to confirm the service binding.
When bound to a GenAI service, the application:
- Automatically detects the service credentials from
VCAP_SERVICESenvironment variable - Extracts API key, base URL, and model name from
credentials.credhub_ref - Configures CrewAI agents to use these credentials
- No manual API key configuration is needed
Example VCAP_SERVICES structure:
VCAP_SERVICES: {
"genai": [
{
"binding_guid": "da6d7b6c-f6a4-4352-8735-55c8f9d498e3",
"binding_name": null,
"credentials": {
"credhub-ref": "/c/a0aae238-99b5-11ee-8608-5ab361936c3e/0b5ee21a-f281-4d56-a3fb-a1d76b07ce7e/da6d7b6c-f6a4-4352-8735-55c8f9d498e3/credentials"
},
"instance_guid": "0b5ee21a-f281-4d56-a3fb-a1d76b07ce7e",
"instance_name": "movie-chatbot-llm",
"label": "genai",
"name": "movie-chatbot-llm",
"plan": "prod-chat-tools-phi4-mini",
"provider": null,
"syslog_drain_url": null,
"tags": [
"genai",
"llm"
],
"volume_mounts": []
}
]
}By default, the application uses SQLite for local development. For production deployments, a managed database service is recommended.
-
Check available database services:
cf marketplace -e postgres
-
Create a database service instance:
cf create-service postgresql PLAN_NAME movie-chatbot-db
-
Bind the database service:
cf bind-service movie-chatbot movie-chatbot-db
-
Configure the application to use the database:
cf set-env movie-chatbot DATABASE_URL_ENV_NAME VCAP_SERVICES_POSTGRESQL_0_CREDENTIALS_URI cf restage movie-chatbot
When switching to a new database service, you need to run migrations:
-
Open an SSH connection to the application:
cf ssh movie-chatbot
-
Navigate to the application directory:
cd app -
Run migrations:
python manage.py migrate
For production deployments, configure high availability to ensure application resilience.
-
Update the manifest with multiple instances:
applications: - name: movie-chatbot memory: 512M instances: 3 # other settings...
Or use the CF CLI:
cf scale movie-chatbot -i 3
When running multiple instances, ensure session persistence:
-
Configure Redis service for session storage:
cf create-service redis PLAN_NAME movie-chatbot-sessions cf bind-service movie-chatbot movie-chatbot-sessions
-
Set environment variables for session configuration:
cf set-env movie-chatbot SESSION_ENGINE django.contrib.sessions.backends.cache cf set-env movie-chatbot SESSION_CACHE_ALIAS default cf restage movie-chatbot
Configure custom health checks for better monitoring:
cf set-health-check movie-chatbot http --endpoint /health
cf set-health-check-timeout movie-chatbot 30Create a health endpoint in your application at /health.
To use a custom domain for your application:
-
Register the domain with your Cloud Foundry instance:
cf create-domain ORG_NAME example.com
-
Map the route to your application:
cf map-route movie-chatbot example.com --hostname booking
This would make your app available at
booking.example.com.
The application memory requirements depend on several factors:
- Base Django application: ~128MB
- CrewAI agent processing: +256MB
- Number of concurrent users: +64MB per 10 users
Recommended configurations:
- Development/Testing: 512MB
- Production (low traffic): 1GB
- Production (high traffic): 2GB+ with multiple instances
Disk requirements:
- Application code: ~50MB
- Dependencies: ~150MB
- Logs & temporary files: ~200MB
- SQLite database (if used): Variable (use managed DB service instead)
Recommended disk quota: 1GB minimum
CPU usage spikes during:
- CrewAI agent processing
- Complex movie searches
- Theater/showtime retrieval
Consider using performance-optimized instance types for production deployments.
Symptoms: Application crashes immediately after deployment
Possible causes and solutions:
-
Missing environment variables:
Check logs for missing configuration:
cf logs movie-chatbot --recent
Solution: Add missing environment variables:
cf set-env movie-chatbot MISSING_VARIABLE value cf restage movie-chatbot
-
Database migration issues:
Check logs for migration errors:
cf logs movie-chatbot --recent | grep -i migrationSolution: Connect via SSH and run migrations manually:
cf ssh movie-chatbot -c "cd app && python manage.py migrate --no-input" -
Memory limits exceeded:
Check if the application is hitting memory limits:
cf app movie-chatbot
Solution: Increase memory allocation:
cf scale movie-chatbot -m 1G
Symptoms: "Technical difficulties with the language model" error message
Possible causes and solutions:
-
Incorrect service binding:
Verify service binding:
cf services cf env movie-chatbot
Solution: Rebind the service:
cf unbind-service movie-chatbot movie-chatbot-llm cf bind-service movie-chatbot movie-chatbot-llm cf restage movie-chatbot
-
Incompatible API format:
Check if the GenAI service provides an OpenAI-compatible API.
Solution: Set a custom base URL if needed:
cf set-env movie-chatbot LLM_BASE_URL custom_endpoint_url cf restage movie-chatbot
Symptoms: Application unable to reach external APIs
Possible causes and solutions:
-
Outbound network restrictions:
Check if outbound network requests are blocked by network policies.
Solution: Configure network policies to allow outbound connections:
cf add-network-policy movie-chatbot --destination-app internet --protocol tcp --port 443
-
API rate limiting:
Check logs for rate limit errors from TMDb or SerpAPI.
Solution: Implement request throttling or upgrade API plans.
Use this checklist before deployment to production:
- Configure all required API keys
- Set
DEBUG=falsein environment - Set appropriate logging configuration
- Run tests locally to verify application functionality
- Build and collect static assets
- Review memory and disk allocations in manifest.yml
- Ensure proper buildpack configuration
- Verify application is running (
cf app movie-chatbot) - Check logs for startup errors (
cf logs movie-chatbot --recent) - Test basic application functionality via browser
- Verify service bindings are working properly
- Test conversation mode switching
- Test movie search and recommendation features
- Test location detection functionality
- Monitor resource usage during testing
- Ensure no API keys are hardcoded in source code
- Verify service binding credentials are properly secured
- Check that DEBUG mode is disabled in production
- Verify CSRF protection is enabled
- Ensure sensitive environment variables are properly set
- Check that database connections are secured (if applicable)
For more detailed information about Cloud Foundry deployment scenarios, refer to:
- Cloud Foundry Deployment Guide - Detailed guide for deploying with different configuration options
For more detailed information, refer to: