CoolFace
Apppublic

Pats182/Tech_Stack_Advisor

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
App README

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:

dockerfile
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:

bash
# Build the Docker image
docker build -t tech-stack-advisor .

# Run the container
docker run -p 7860:7860 tech-stack-advisor

Access 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:

  1. 1.Checks out the repository
  2. 2.Pushes changes to Hugging Face Spaces
  3. 3.Triggers a rebuild of the Docker container on Hugging Face

Setup Instructions

To replicate this CI/CD setup:

  1. 1.Create a Hugging Face Space
  2. 2.Go to Hugging Face Spaces
  3. 3.Create a new Space with Docker SDK
  4. 4.Note your Space name (e.g., username/space-name)
  1. 1.Generate Hugging Face Token
  2. 2.Go to Hugging Face Settings > Tokens
  3. 3.Create a new token with "Write" permissions
  4. 4.Copy the token
  1. 1.Add Token to GitHub Secrets
  2. 2.Go to your GitHub repository โ†’ Settings โ†’ Secrets and variables โ†’ Actions
  3. 3.Create a new secret named HFTSA_TOKEN
  4. 4.Paste your Hugging Face token as the value
  1. 1.Update Workflow File
  2. 2.Modify .github/workflows/Sync to Hugging Face hub/main.yml with your Space URL
  3. 3.Commit and push to trigger the deployment

GitHub Actions Workflow

yaml
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

  1. 1.Clone the repository
bash
   git clone https://github.com/robinpats182/Tech-Stack-Advisor.git
   cd Tech-Stack-Advisor
  1. 1.Install dependencies
bash
   pip install -r requirements.txt
  1. 1.Run the application
bash
   python app.py
  1. 1.Access the app
  2. 2.Open your browser to http://localhost:7860

๐Ÿ“ Deployment Steps

  1. 1.Make changes to your code locally
  2. 2.Commit your changes:
bash
   git add .
   git commit -m "Your commit message"
  1. 1.Push to GitHub:
bash
   git push origin main
  1. 1.GitHub Actions automatically deploys to Hugging Face Spaces
  2. 2.Wait for the build to complete on Hugging Face

๐Ÿ› Troubleshooting

Common Issues

Docker build fails on Hugging Face:

  • โ€”Ensure Dockerfile has a capital 'D'
  • โ€”Verify requirements.txt has compatible versions
  • โ€”Check Hugging Face build logs for specific errors

Authentication errors in GitHub Actions:

  • โ€”Verify HFTSA_TOKEN secret is set correctly
  • โ€”Ensure token has "Write" permissions
  • โ€”Check that the token hasn't expired

Application doesn't start:

  • โ€”Verify app.py has demo.launch(server_name="0.0.0.0", server_port=7860)
  • โ€”Check README.md has sdk: docker and app_port: 7860
  • โ€”Review container logs on Hugging Face

๐Ÿ“š Learning Resources

๐Ÿ™ 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!