Tabble-v1 / HUGGINGFACE_README.md
Shyamnath's picture
Initial commit with Git LFS
80feb1b
# Deploying to Hugging Face Spaces
This guide explains how to deploy the FastAPI backend to Hugging Face Spaces using Docker.
## Prerequisites
1. A Hugging Face account
2. Git installed on your machine
3. Docker installed (for local testing)
## Steps to Deploy
1. Create a new Space on Hugging Face:
- Go to https://huggingface.co/spaces
- Click "Create new Space"
- Select "Docker" as the SDK
- Choose a name for your space
- Set visibility (public/private)
2. Clone the new Space repository:
```bash
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
```
3. Copy the following files to the cloned repository:
- `Dockerfile`
- `requirements.txt`
- `app/` directory
- `templates/` directory
- `run.py`
- `tabble_new.db`
4. Update your environment variables:
- Go to your Space's Settings
- Add any necessary environment variables
- Make sure to add any sensitive information as secrets
5. Commit and push your changes:
```bash
git add .
git commit -m "Initial commit"
git push
```
## Local Testing
Before deploying to Hugging Face, you can test locally using Docker Compose:
1. Build and run the container:
```bash
docker-compose up --build
```
2. Access the API at `http://localhost:7860`
## Important Notes
1. The Dockerfile uses port 7860 as required by Hugging Face Spaces
2. Make sure your database is properly initialized before deployment
3. Static files and images should be stored in the appropriate directories
4. Any changes to the code require a new commit and push to update the Space
## Monitoring
- Monitor your Space's logs through the Hugging Face interface
- Check the Space's metrics for usage statistics
- Use the Space's terminal for debugging if needed
## Troubleshooting
If you encounter issues:
1. Check the Space's logs for error messages
2. Verify all environment variables are set correctly
3. Ensure all required files are present in the repository
4. Test the application locally using Docker Compose before deploying