mco-protocol / hf_spaces_deployment.md
paradiseDev's picture
Upload 18 files
6b71d9d verified

Hugging Face Spaces Deployment Guide

This guide explains how to deploy the MCO Protocol hackathon submission to Hugging Face Spaces using Docker.

Prerequisites

  • A Hugging Face account
  • Modal API credentials
  • Basic familiarity with Git and Docker

Deployment Steps

1. Create a New Space

  1. Go to Hugging Face and sign in
  2. Click on your profile picture and select "New Space"
  3. Choose a name for your Space
  4. Select "Docker" as the Space SDK
  5. Choose "Public" or "Private" visibility as needed
  6. Click "Create Space"

2. Configure Secrets

Add your Modal API credentials as secrets:

  1. Go to the Space settings
  2. Click on the "Variables and Secrets" tab
  3. Add the following secrets:
    • MODAL_TOKEN_ID: Your Modal token ID
    • MODAL_TOKEN_SECRET: Your Modal token secret

3. Upload Files

You can upload the files using Git:

# Clone the Space repository
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME

# Copy all files to the repository
cp -r /path/to/mco-hackathon-final/* /path/to/cloned/repo/

# Commit and push
cd /path/to/cloned/repo
git add .
git commit -m "Initial commit"
git push

4. Verify Deployment

  1. Wait for the build to complete (this may take a few minutes)
  2. Visit your Space URL to see the deployed application
  3. Test the functionality to ensure everything works as expected

Docker Configuration

The included Dockerfile sets up the environment with:

  • Python 3.9
  • Node.js 16.x
  • All required Python dependencies
  • MCO Protocol npm package
  • Proper port exposure for Gradio

Troubleshooting

If you encounter issues with the deployment:

  1. Check the build logs in the Space for any errors
  2. Verify that all secrets are correctly set
  3. Ensure the Docker build completes successfully
  4. Check that the app starts correctly after deployment

Additional Resources