Deploying to Hugging Face Spaces
This guide explains how to host your DCRM API on Hugging Face Spaces using Docker.
Prerequisites
- Hugging Face Account: Sign up here.
- Google API Key: Required for the app to run.
Step 1: Create a Space
- Go to huggingface.co/new-space.
- Space Name: e.g.,
dcrm-api. - License: MIT or Apache 2.0.
- SDK: Select Docker.
- Clean Template: Choose "Blank".
- Click Create Space.
Step 2: Push Your Code
You can push your code directly via Git:
# Initialize git if you haven't
git init
# Add the Hugging Face remote (found in your Space's "Clone repository" button)
git remote add space https://huggingface.co/spaces/YOUR_USERNAME/dcrm-api
# Push
git add .
git commit -m "Deploy to HF"
git push space main
Step 3: Configure Settings
- Go to your Space's Settings tab.
- Scroll to Variables and secrets.
- Click New Secret.
- Name:
GOOGLE_API_KEY - Value: [Your Google API Key]
- Name:
- The Space will restart automatically.
API Usage
Your API will be available at:
https://YOUR_USERNAME-dcrm-api.hf.space
Example Health Check:
https://YOUR_USERNAME-dcrm-api.hf.space/api/health