ai-code-scanner-ui / deploy.sh
mubi-613's picture
Initial clean commit: Fixed security issues and removed heavy checkpoints
168ae1c
Raw
History Blame Contribute Delete
2.7 kB
#!/bin/bash
# AI Code Security Scanner - Deployment Script
# Usage: ./deploy.sh [huggingface|docker|local]
set -e # Exit on error
echo "πŸš€ AI Code Security Scanner - Deployment"
echo "========================================"
DEPLOY_TARGET=${1:-"huggingface"}
case $DEPLOY_TARGET in
"huggingface")
echo "🎯 Deploying to Hugging Face Spaces..."
# Check for HF_TOKEN
if [ -z "$HF_TOKEN" ]; then
echo "❌ HF_TOKEN environment variable not set"
echo "Please set your Hugging Face token:"
echo "export HF_TOKEN=your_token_here"
exit 1
fi
# Prepare files
cp app_hf.py app.py
cp requirements_hf.txt requirements.txt
# Clone space (assuming it exists)
git clone https://$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/code-security-scanner
cd code-security-scanner
# Copy files
cp ../app.py .
cp ../requirements.txt .
cp ../combined_detector.py .
cp ../rule_detector.py .
cp ../fix_generator.py .
# Commit and push
git add .
git commit -m "Deploy: $(date)"
git push origin main
echo "βœ… Deployed to Hugging Face!"
echo "🌐 Your space: https://huggingface.co/spaces/$HF_USERNAME/code-security-scanner"
;;
"docker")
echo "🐳 Building Docker image..."
# Build image
docker build -t ai-code-security-scanner:latest .
# Run container
docker run -d -p 8501:8501 --name code-scanner ai-code-security-scanner:latest
echo "βœ… Docker container running!"
echo "🌐 Access at: http://localhost:8501"
;;
"local")
echo "πŸ’» Setting up local development..."
# Create virtual environment
python -m venv venv
# Activate (platform specific)
if [ "$OSTYPE" = "msys" ] || [ "$OSTYPE" = "cygwin" ]; then
# Windows
source venv/Scripts/activate
else
# Unix/Linux/Mac
source venv/bin/activate
fi
# Install dependencies
pip install --upgrade pip
pip install -r requirements.txt
echo "βœ… Local setup complete!"
echo "πŸ‘‰ Activate: source venv/bin/activate"
echo "πŸ‘‰ Run: streamlit run app.py"
;;
*)
echo "❌ Unknown deployment target: $DEPLOY_TARGET"
echo "Usage: ./deploy.sh [huggingface|docker|local]"
exit 1
;;
esac
echo ""
echo "πŸŽ‰ Deployment completed successfully!"