+91 9873530045
admin@learnwithfrahimcom
Mon - Sat : 09 AM - 09 PM

Step 6 - Deploy Chatbot to Streamlit Cloud / Cloud Run

Step 6 — Deploy Chatbot to Streamlit Cloud / Cloud Run


Make your Streamlit chatbot accessible to your team via a URL.

Step 6A — Deploy to Streamlit Cloud (Recommended for Rapid Demos)

  1. Ensure your chatbot folder contains:
    • app.py
    • requirements.txt (all dependencies: streamlit, vertexai, python-dotenv, etc.)
    • .streamlit/config.toml (optional: set server.port, theme, etc.)
  2. Create a GitHub repository for your project and push the folder:
  3. git init
    git add .
    git commit -m "Initial commit"
    git branch -M main
    git remote add origin https://github.com/yourusername/your-chatbot.git
    git push -u origin main
  4. Go to Streamlit Cloud and sign in (use your GitHub account).
  5. Click New App → Select Repository → Branch → Directory and click Deploy.
  6. Wait a few minutes — your app URL will look like: https://your-chatbot.streamlit.app
  7. Open the URL to test. Everyone with the URL can now access your chatbot.
Tip: Streamlit Cloud automatically installs packages listed in requirements.txt.

Step 6B — Deploy to GCP Cloud Run (Optional: More Control / Custom Domain)

  1. Install Google Cloud SDK if not already:
    https://cloud.google.com/sdk/docs/install
  2. Authenticate and set project:
    gcloud auth login
    gcloud config set project YOUR_PROJECT_ID
  3. Create Dockerfile in your project root:
    # Use official Python base image
    FROM python:3.12-slim
    
    # Set working directory
    WORKDIR /app
    
    # Copy files
    COPY . /app
    
    # Install dependencies
    RUN pip install --upgrade pip
    RUN pip install -r requirements.txt
    
    # Expose Streamlit port
    EXPOSE 8501
    
    # Command to run
    CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
            
  4. Build Docker image:
    gcloud builds submit --tag gcr.io/YOUR_PROJECT_ID/chatbot
  5. Deploy to Cloud Run:
    gcloud run deploy chatbot \
      --image gcr.io/YOUR_PROJECT_ID/chatbot \
      --platform managed \
      --region us-central1 \
      --allow-unauthenticated
  6. GCP will provide a URL like https://chatbot-xxxxxx-uc.a.run.app
  7. Open the URL and test. Your chatbot is now running fully on cloud infrastructure.
Cloud Run allows scaling, custom domains, and more control over resource usage, but requires Docker.

Step 6C — Important Tips

  • Ensure your .env with GCP credentials is either in Cloud Secrets or replaced by ADC (Application Default Credentials) when deploying.
  • Check logs if your app fails:
    streamlit logs
    gcloud logs read --project YOUR_PROJECT_ID
  • For Streamlit Cloud, keep requirements.txt updated with all packages.
  • Test locally first:
    streamlit run app.py
  • Use avatars as emojis or public URLs so they load correctly in the cloud deployment.

Step 6D — Quick Checklist

StepDone?
Push project to GitHub
Streamlit Cloud: Deploy App
Cloud Run: Docker build & deploy
Test URL on browser
Ensure GCP authentication works
Check logs if error occurs
Streamlit + Vertex AI Chatbot Course — Step 6 of 10