-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
143 lines (120 loc) · 3.93 KB
/
deploy.sh
File metadata and controls
143 lines (120 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
# Eye Tracking App Deployment Script
# Supports local, Docker, and cloud deployment
set -e
echo "🚀 Eye Tracking App Deployment Script"
echo "======================================"
# Function to check dependencies
check_dependencies() {
echo "📋 Checking dependencies..."
# Check Python
if ! command -v python3 &> /dev/null; then
echo "❌ Python 3 is required but not installed."
exit 1
fi
# Check pip
if ! command -v pip &> /dev/null; then
echo "❌ pip is required but not installed."
exit 1
fi
echo "✅ Dependencies check passed"
}
# Function for local deployment
deploy_local() {
echo "🏠 Starting local deployment..."
# Create virtual environment if it doesn't exist
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3 -m venv venv
fi
# Activate virtual environment
source venv/bin/activate || source venv/Scripts/activate
# Upgrade pip
pip install --upgrade pip
# Install requirements
echo "📦 Installing requirements..."
pip install -r requirements_streamlit.txt
# Start the application
echo "🎬 Starting Streamlit application..."
echo "💡 The app will be available at: http://localhost:8501"
echo "🛑 Press Ctrl+C to stop the application"
streamlit run streamlit_app.py
}
# Function for Docker deployment
deploy_docker() {
echo "🐳 Starting Docker deployment..."
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo "❌ Docker is required but not installed."
echo "Please install Docker from: https://docs.docker.com/get-docker/"
exit 1
fi
# Build Docker image
echo "🔨 Building Docker image..."
docker build -t eye-tracking-app .
# Run Docker container
echo "🚀 Starting Docker container..."
echo "💡 The app will be available at: http://localhost:8501"
echo "🛑 Press Ctrl+C to stop the container"
docker run -p 8501:8501 \
--name eye-tracking-container \
--rm \
eye-tracking-app
}
# Function for cloud deployment (Streamlit Cloud)
deploy_cloud() {
echo "☁️ Preparing for cloud deployment..."
echo "📝 Cloud deployment checklist:"
echo "1. Push your code to GitHub"
echo "2. Go to https://share.streamlit.io"
echo "3. Connect your GitHub repository"
echo "4. Set the main file to: streamlit_app.py"
echo "5. Set requirements file to: requirements_streamlit.txt"
echo ""
echo "📋 Repository structure should be:"
echo " - streamlit_app.py (main application)"
echo " - requirements_streamlit.txt (dependencies)"
echo " - .streamlit/config.toml (configuration)"
echo ""
echo "🔗 Alternative cloud platforms:"
echo " - Heroku: Use the provided Dockerfile"
echo " - Railway: Deploy directly from GitHub"
echo " - Google Cloud Run: Use Docker deployment"
echo " - AWS App Runner: Use Docker deployment"
}
# Function to show help
show_help() {
echo "Usage: ./deploy.sh [option]"
echo ""
echo "Options:"
echo " local - Deploy locally with virtual environment"
echo " docker - Deploy using Docker container"
echo " cloud - Show cloud deployment instructions"
echo " help - Show this help message"
echo ""
echo "Examples:"
echo " ./deploy.sh local # Start local development server"
echo " ./deploy.sh docker # Build and run Docker container"
echo " ./deploy.sh cloud # Show cloud deployment guide"
}
# Main script logic
case "${1:-local}" in
"local")
check_dependencies
deploy_local
;;
"docker")
deploy_docker
;;
"cloud")
deploy_cloud
;;
"help"|"-h"|"--help")
show_help
;;
*)
echo "❌ Unknown option: $1"
show_help
exit 1
;;
esac