Add deployment configuration (Dockerfile, docker-compose, deployment scripts)
Browse files- Dockerfile +26 -0
- README.md +57 -0
- deploy-railway.sh +25 -0
- docker-compose.yml +40 -0
- setup-render.sh +27 -0
- test-deployment.sh +46 -0
Dockerfile
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
# Set working directory
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
# Install system dependencies
|
| 7 |
+
RUN apt-get update && apt-get install -y \
|
| 8 |
+
gcc \
|
| 9 |
+
g++ \
|
| 10 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
+
|
| 12 |
+
# Copy requirements and install Python dependencies
|
| 13 |
+
COPY requirements.txt .
|
| 14 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
+
|
| 16 |
+
# Copy application code
|
| 17 |
+
COPY . .
|
| 18 |
+
|
| 19 |
+
# Create necessary directories
|
| 20 |
+
RUN mkdir -p backend/runs backend/tmp frontend/web
|
| 21 |
+
|
| 22 |
+
# Expose port
|
| 23 |
+
EXPOSE 8000
|
| 24 |
+
|
| 25 |
+
# Run the application
|
| 26 |
+
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
README.md
CHANGED
|
@@ -91,6 +91,63 @@ Once the application is live on `http://localhost:8000`, follow these steps:
|
|
| 91 |
|
| 92 |
---
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
## 🤝 Contributing
|
| 95 |
|
| 96 |
Contributions are welcome! Please feel free to submit a Pull Request or open an Issue for any bugs, feature requests, or improvements.
|
|
|
|
| 91 |
|
| 92 |
---
|
| 93 |
|
| 94 |
+
## 🌐 Deployment Options
|
| 95 |
+
|
| 96 |
+
### Quick Deploy (Recommended for Beginners)
|
| 97 |
+
|
| 98 |
+
#### 1. Railway (Easiest - 5 minutes)
|
| 99 |
+
```bash
|
| 100 |
+
# Install Railway CLI
|
| 101 |
+
npm install -g @railway/cli
|
| 102 |
+
|
| 103 |
+
# Login and deploy
|
| 104 |
+
railway login
|
| 105 |
+
railway init automl-studio
|
| 106 |
+
railway up
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
#### 2. Render (Free tier available)
|
| 110 |
+
```bash
|
| 111 |
+
# Run setup script
|
| 112 |
+
bash setup-render.sh
|
| 113 |
+
|
| 114 |
+
# Then deploy via Render dashboard
|
| 115 |
+
# Go to render.com and connect your GitHub repo
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
#### 3. Docker (Most Flexible)
|
| 119 |
+
```bash
|
| 120 |
+
# Build and run with Docker Compose
|
| 121 |
+
docker-compose up -d
|
| 122 |
+
|
| 123 |
+
# Access at http://localhost:8000
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
### Advanced Deployment
|
| 127 |
+
|
| 128 |
+
#### AWS/GCP/Azure
|
| 129 |
+
- Use Elastic Beanstalk, App Engine, or App Service
|
| 130 |
+
- Add RDS/Cloud SQL for database persistence
|
| 131 |
+
- Use Cloud Storage for model artifacts
|
| 132 |
+
|
| 133 |
+
#### Heroku
|
| 134 |
+
```bash
|
| 135 |
+
# Create Heroku app
|
| 136 |
+
heroku create your-automl-studio
|
| 137 |
+
|
| 138 |
+
# Deploy
|
| 139 |
+
git push heroku main
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
### Production Considerations
|
| 143 |
+
- **Database**: Add PostgreSQL for production data persistence
|
| 144 |
+
- **Redis**: Required for background job queuing
|
| 145 |
+
- **Storage**: Use cloud storage (S3, GCS) for large model files
|
| 146 |
+
- **Scaling**: Consider load balancer for multiple instances
|
| 147 |
+
- **Security**: Add authentication, rate limiting, and input validation
|
| 148 |
+
|
| 149 |
+
---
|
| 150 |
+
|
| 151 |
## 🤝 Contributing
|
| 152 |
|
| 153 |
Contributions are welcome! Please feel free to submit a Pull Request or open an Issue for any bugs, feature requests, or improvements.
|
deploy-railway.sh
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Railway Deployment Script
|
| 4 |
+
echo "🚀 Deploying AutoML Studio to Railway..."
|
| 5 |
+
|
| 6 |
+
# Install Railway CLI if not present
|
| 7 |
+
if ! command -v railway &> /dev/null; then
|
| 8 |
+
echo "Installing Railway CLI..."
|
| 9 |
+
npm install -g @railway/cli
|
| 10 |
+
fi
|
| 11 |
+
|
| 12 |
+
# Login to Railway (user will need to authenticate)
|
| 13 |
+
railway login
|
| 14 |
+
|
| 15 |
+
# Initialize Railway project
|
| 16 |
+
railway init automl-studio
|
| 17 |
+
|
| 18 |
+
# Set environment variables
|
| 19 |
+
railway variables set REDIS_URL=redis://redis:6379/0
|
| 20 |
+
|
| 21 |
+
# Deploy
|
| 22 |
+
railway up
|
| 23 |
+
|
| 24 |
+
echo "✅ Deployment complete!"
|
| 25 |
+
echo "Your app will be available at the URL shown above"
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
web:
|
| 5 |
+
build: .
|
| 6 |
+
ports:
|
| 7 |
+
- "8000:8000"
|
| 8 |
+
volumes:
|
| 9 |
+
- ./backend/runs:/app/backend/runs
|
| 10 |
+
- ./backend/tmp:/app/backend/tmp
|
| 11 |
+
environment:
|
| 12 |
+
- REDIS_URL=redis://redis:6379/0
|
| 13 |
+
depends_on:
|
| 14 |
+
- redis
|
| 15 |
+
restart: unless-stopped
|
| 16 |
+
|
| 17 |
+
redis:
|
| 18 |
+
image: redis:7-alpine
|
| 19 |
+
ports:
|
| 20 |
+
- "6379:6379"
|
| 21 |
+
volumes:
|
| 22 |
+
- redis_data:/data
|
| 23 |
+
restart: unless-stopped
|
| 24 |
+
|
| 25 |
+
# Optional: Add PostgreSQL if using database features
|
| 26 |
+
# db:
|
| 27 |
+
# image: postgres:15-alpine
|
| 28 |
+
# environment:
|
| 29 |
+
# POSTGRES_DB: automl
|
| 30 |
+
# POSTGRES_USER: automl
|
| 31 |
+
# POSTGRES_PASSWORD: your_password
|
| 32 |
+
# volumes:
|
| 33 |
+
# - postgres_data:/var/lib/postgresql/data
|
| 34 |
+
# ports:
|
| 35 |
+
# - "5432:5432"
|
| 36 |
+
# restart: unless-stopped
|
| 37 |
+
|
| 38 |
+
volumes:
|
| 39 |
+
redis_data:
|
| 40 |
+
# postgres_data:
|
setup-render.sh
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Render Deployment Setup
|
| 4 |
+
echo "🚀 Setting up AutoML Studio for Render deployment..."
|
| 5 |
+
|
| 6 |
+
# Create render.yaml for multi-service deployment
|
| 7 |
+
cat > render.yaml << EOF
|
| 8 |
+
services:
|
| 9 |
+
- type: web
|
| 10 |
+
name: automl-studio
|
| 11 |
+
runtime: python3
|
| 12 |
+
buildCommand: pip install -r requirements.txt
|
| 13 |
+
startCommand: uvicorn backend.main:app --host 0.0.0.0 --port \$PORT
|
| 14 |
+
envVars:
|
| 15 |
+
- key: REDIS_URL
|
| 16 |
+
value: redis://redis:6379/0
|
| 17 |
+
|
| 18 |
+
- type: redis
|
| 19 |
+
name: automl-redis
|
| 20 |
+
ipAllowList: [] # Only accessible by other services
|
| 21 |
+
EOF
|
| 22 |
+
|
| 23 |
+
echo "✅ Render configuration created!"
|
| 24 |
+
echo "1. Go to https://render.com"
|
| 25 |
+
echo "2. Connect your GitHub repository"
|
| 26 |
+
echo "3. Use the render.yaml file for deployment"
|
| 27 |
+
echo "4. Or deploy the web service manually with the commands above"
|
test-deployment.sh
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Deployment Test Script
|
| 4 |
+
echo "🧪 Testing AutoML Studio deployment readiness..."
|
| 5 |
+
|
| 6 |
+
# Check if required files exist
|
| 7 |
+
files=("requirements.txt" "backend/main.py" "frontend/app.py" "Dockerfile" "docker-compose.yml")
|
| 8 |
+
for file in "${files[@]}"; do
|
| 9 |
+
if [ -f "$file" ]; then
|
| 10 |
+
echo "✅ $file found"
|
| 11 |
+
else
|
| 12 |
+
echo "❌ $file missing"
|
| 13 |
+
exit 1
|
| 14 |
+
fi
|
| 15 |
+
done
|
| 16 |
+
|
| 17 |
+
# Test Python imports
|
| 18 |
+
echo "Testing Python dependencies..."
|
| 19 |
+
python3 -c "
|
| 20 |
+
import fastapi
|
| 21 |
+
import uvicorn
|
| 22 |
+
import pandas
|
| 23 |
+
import sklearn
|
| 24 |
+
import xgboost
|
| 25 |
+
print('✅ All core dependencies available')
|
| 26 |
+
"
|
| 27 |
+
|
| 28 |
+
# Check if ports are available
|
| 29 |
+
if lsof -Pi :8000 -sTCP:LISTEN -t >/dev/null; then
|
| 30 |
+
echo "⚠️ Port 8000 is already in use"
|
| 31 |
+
else
|
| 32 |
+
echo "✅ Port 8000 is available"
|
| 33 |
+
fi
|
| 34 |
+
|
| 35 |
+
if lsof -Pi :6379 -sTCP:LISTEN -t >/dev/null; then
|
| 36 |
+
echo "⚠️ Port 6379 (Redis) is already in use"
|
| 37 |
+
else
|
| 38 |
+
echo "✅ Port 6379 (Redis) is available"
|
| 39 |
+
fi
|
| 40 |
+
|
| 41 |
+
echo "🎉 Deployment test complete!"
|
| 42 |
+
echo ""
|
| 43 |
+
echo "Ready to deploy with:"
|
| 44 |
+
echo " Railway: railway up"
|
| 45 |
+
echo " Docker: docker-compose up -d"
|
| 46 |
+
echo " Local: bash run.sh"
|