Pats182/Tech_Stack_Advisor
Tech Stack Advisor
A Gradio-based web application that helps recommend technology stacks based on your project requirements. This project demonstrates containerization with Docker and automated deployment to Hugging Face Spaces using GitHub Actions CI/CD.
๐ Live Demo
Check out the live application: Tech Stack Advisor on Hugging Face Spaces
๐ Project Overview
This project was developed as part of the AI/ML with Docker course at School of DevOps. The application was created by Gourav Shah, and this repository demonstrates the process of:
- Containerizing a Python/Gradio application with Docker
- Setting up automated CI/CD pipeline with GitHub Actions
- Deploying to Hugging Face Spaces
๐ ๏ธ Tech Stack
- Python 3.11 - Programming language
- Gradio - Web UI framework for machine learning applications
- Docker - Containerization platform
- GitHub Actions - CI/CD automation
- Hugging Face Spaces - Deployment platform
๐ฆ Project Structure
Tech-Stack-Advisor/
โโโ app.py # Main Gradio application
โโโ requirements.txt # Python dependencies
โโโ Dockerfile # Docker configuration
โโโ .github/
โ โโโ workflows/
โ โโโ Sync to Hugging Face hub # GitHub Actions workflow
โโโ README.md # Project documentation๐ณ Docker Setup
Dockerfile
The application is containerized using Docker with the following configuration:
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 7860
CMD ["python", "app.py"]Building Locally
To build and run the Docker container locally:
# Build the Docker image
docker build -t tech-stack-advisor .
# Run the container
docker run -p 7860:7860 tech-stack-advisorAccess the application at http://localhost:7860
๐ CI/CD Pipeline
This project uses GitHub Actions for automated deployment to Hugging Face Spaces. Every push to the main branch triggers the deployment workflow.
Workflow Configuration
The workflow automatically:
- Checks out the repository
- Pushes changes to Hugging Face Spaces
- Triggers a rebuild of the Docker container on Hugging Face
Setup Instructions
To replicate this CI/CD setup:
- Create a Hugging Face Space
- Go to Hugging Face Spaces
- Create a new Space with Docker SDK
- Note your Space name (e.g.,
username/space-name)
- Generate Hugging Face Token
- Go to Hugging Face Settings > Tokens
- Create a new token with "Write" permissions
- Copy the token
- Add Token to GitHub Secrets
- Go to your GitHub repository โ Settings โ Secrets and variables โ Actions
- Create a new secret named
HFTSA_TOKEN - Paste your Hugging Face token as the value
- Update Workflow File
- Modify
.github/workflows/Sync to Hugging Face hub/main.ymlwith your Space URL - Commit and push to trigger the deployment
GitHub Actions Workflow
name: Sync to Hugging Face hub
on:
push:
branches: [main]
workflow_dispatch:
jobs:
sync-to-hub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: Push to Hugging Face
env:
HFTSA_TOKEN: ${{ secrets.HFTSA_TOKEN }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git push https://Pats182:$HFTSA_TOKEN@huggingface.co/spaces/Pats182/Tech_Stack_Advisor main --force๐ฆ Getting Started
Prerequisites
- Python 3.11+
- Docker (for local development)
- Git
- GitHub account
- Hugging Face account
Local Development
- Clone the repository
git clone https://github.com/robinpats182/Tech-Stack-Advisor.git
cd Tech-Stack-Advisor- Install dependencies
pip install -r requirements.txt- Run the application
python app.py- Access the app
- Open your browser to
http://localhost:7860
๐ Deployment Steps
- Make changes to your code locally
- Commit your changes:
git add .
git commit -m "Your commit message"- Push to GitHub:
git push origin main- GitHub Actions automatically deploys to Hugging Face Spaces
- Wait for the build to complete on Hugging Face
๐ Troubleshooting
Common Issues
Docker build fails on Hugging Face:
- Ensure
Dockerfilehas a capital 'D' - Verify
requirements.txthas compatible versions - Check Hugging Face build logs for specific errors
Authentication errors in GitHub Actions:
- Verify
HFTSA_TOKENsecret is set correctly - Ensure token has "Write" permissions
- Check that the token hasn't expired
Application doesn't start:
- Verify
app.pyhasdemo.launch(server_name="0.0.0.0", server_port=7860) - Check README.md has
sdk: dockerandapp_port: 7860 - Review container logs on Hugging Face
๐ Learning Resources
- Docker Documentation
- Gradio Documentation
- Hugging Face Spaces Documentation
- GitHub Actions Documentation
๐ Credits
- Application Creator: Gourav Shah
- Course: AI/ML with Docker at School of DevOps
- Dockerization & Deployment: Implementation of CI/CD pipeline and deployment workflow
๐ License
This project is part of an educational course at School of DevOps.
๐ค Contributing
This is an educational project. Feel free to fork and experiment with your own modifications!
