update deploy script to be stricter about dependencies
This commit is contained in:
parent
0d54765bbe
commit
49bce41f6a
2 changed files with 108 additions and 15 deletions
52
README.md
52
README.md
|
|
@ -365,15 +365,17 @@ Key Files Explained:
|
|||
|
||||
This is the recommended method for production deployment. The `deploy.sh` script automates the entire deployment process.
|
||||
|
||||
**Prerequisites:**
|
||||
**Prerequisites (ALL REQUIRED):**
|
||||
- Ubuntu/Debian or CentOS/RHEL server
|
||||
- Apache 2.4+ or Nginx
|
||||
- PHP 7.4+ with PHP-FPM
|
||||
- Python 3.8+
|
||||
- Composer
|
||||
- FFmpeg
|
||||
- Python 3.8+ with pip and venv
|
||||
- **Composer** (PHP dependency manager) - deploy script will fail without it
|
||||
- **FFmpeg** (audio processing) - transcription will fail without it
|
||||
- Root/sudo access
|
||||
|
||||
**The deploy script checks for these and will exit with an error if any are missing.**
|
||||
|
||||
### Initial Setup
|
||||
|
||||
**Step 1: Install system dependencies**
|
||||
|
|
@ -551,6 +553,48 @@ Production Server:
|
|||
|
||||
### Troubleshooting Deployment
|
||||
|
||||
**"Failed to open vendor/autoload.php" error:**
|
||||
```
|
||||
PHP Fatal error: Failed opening required '/var/www/html/voice2txt/vendor/autoload.php'
|
||||
```
|
||||
|
||||
This means Composer dependencies are missing. Fix:
|
||||
```bash
|
||||
# 1. Check if Composer is installed
|
||||
composer --version
|
||||
|
||||
# If not installed:
|
||||
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
# 2. Install dependencies in backend
|
||||
cd /opt/voice2text
|
||||
sudo composer install --no-dev --optimize-autoloader
|
||||
|
||||
# 3. Verify vendor/ was created
|
||||
ls -la vendor/autoload.php
|
||||
|
||||
# 4. Copy to frontend
|
||||
sudo cp -r vendor /var/www/html/voice2txt/
|
||||
|
||||
# 5. Fix permissions
|
||||
sudo chown -R www-data:www-data /var/www/html/voice2txt/vendor
|
||||
|
||||
# 6. Verify frontend has it
|
||||
ls -la /var/www/html/voice2txt/vendor/autoload.php
|
||||
|
||||
# 7. Restart Apache
|
||||
sudo systemctl restart apache2
|
||||
```
|
||||
|
||||
**Deploy script fails with "Composer not found":**
|
||||
The deploy script now REQUIRES Composer to be installed. Install it:
|
||||
```bash
|
||||
curl -sS https://getcomposer.org/installer | php
|
||||
sudo mv composer.phar /usr/local/bin/composer
|
||||
sudo chmod +x /usr/local/bin/composer
|
||||
composer --version
|
||||
```
|
||||
|
||||
**Service won't start:**
|
||||
```bash
|
||||
# Check service logs
|
||||
|
|
|
|||
71
deploy.sh
71
deploy.sh
|
|
@ -129,6 +129,33 @@ print_success "Backend directory exists: $BACKEND_DIR"
|
|||
# Change to backend directory
|
||||
cd "$BACKEND_DIR"
|
||||
|
||||
# Check for required system dependencies
|
||||
print_header "Checking Required Dependencies"
|
||||
|
||||
# Check Python (REQUIRED)
|
||||
if ! command -v python3 &> /dev/null; then
|
||||
print_error "Python 3 is not installed (REQUIRED)"
|
||||
print_info "Install: sudo apt install python3 python3-venv python3-pip"
|
||||
exit 1
|
||||
fi
|
||||
print_success "Python 3 found: $(python3 --version)"
|
||||
|
||||
# Check Composer (REQUIRED for PHP dependencies)
|
||||
if ! command -v composer &> /dev/null; then
|
||||
print_error "Composer is not installed (REQUIRED)"
|
||||
print_info "Install: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer"
|
||||
exit 1
|
||||
fi
|
||||
print_success "Composer found: $(composer --version | head -n 1)"
|
||||
|
||||
# Check FFmpeg (REQUIRED for audio processing)
|
||||
if ! command -v ffmpeg &> /dev/null; then
|
||||
print_error "FFmpeg is not installed (REQUIRED)"
|
||||
print_info "Install: sudo apt install ffmpeg"
|
||||
exit 1
|
||||
fi
|
||||
print_success "FFmpeg found: $(ffmpeg -version | head -n 1 | cut -d' ' -f3)"
|
||||
|
||||
# Detect if this is first deployment
|
||||
FIRST_DEPLOY=false
|
||||
if [ ! -f "$SERVICE_PATH" ]; then
|
||||
|
|
@ -197,15 +224,25 @@ if [ "$FRONTEND_ONLY" != true ]; then
|
|||
run_command venv/bin/pip install -r requirements.txt
|
||||
print_success "Python dependencies installed"
|
||||
|
||||
# Install/update Composer dependencies
|
||||
if command -v composer &> /dev/null; then
|
||||
print_info "Installing PHP dependencies (Composer)..."
|
||||
run_command composer install --no-dev --optimize-autoloader
|
||||
print_success "Composer dependencies installed"
|
||||
else
|
||||
print_warning "Composer not found - skipping PHP dependencies"
|
||||
# Install/update Composer dependencies (REQUIRED)
|
||||
print_info "Installing PHP dependencies (Composer)..."
|
||||
run_command composer install --no-dev --optimize-autoloader
|
||||
|
||||
# VERIFY vendor/ directory was created
|
||||
if [ ! -d "vendor" ]; then
|
||||
print_error "Composer dependencies failed to install - vendor/ directory missing!"
|
||||
print_info "Try running: composer install --verbose"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "vendor/autoload.php" ]; then
|
||||
print_error "Composer autoload.php is missing!"
|
||||
print_info "This indicates a broken Composer installation"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_success "Composer dependencies installed and verified"
|
||||
|
||||
# Create outputs directory if it doesn't exist
|
||||
if [ ! -d "outputs" ]; then
|
||||
print_info "Creating outputs directory..."
|
||||
|
|
@ -308,12 +345,24 @@ if [ "$BACKEND_ONLY" != true ]; then
|
|||
run_command cp "$BACKEND_DIR/V2T.svg" "$FRONTEND_DIR/"
|
||||
fi
|
||||
|
||||
# Composer vendor directory
|
||||
if [ -d "$BACKEND_DIR/vendor" ]; then
|
||||
print_info "Copying Composer dependencies..."
|
||||
run_command cp -r "$BACKEND_DIR/vendor" "$FRONTEND_DIR/"
|
||||
# Composer vendor directory (REQUIRED)
|
||||
if [ ! -d "$BACKEND_DIR/vendor" ]; then
|
||||
print_error "vendor/ directory not found in backend!"
|
||||
print_info "This should have been created during backend deployment"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_info "Copying Composer dependencies..."
|
||||
run_command cp -r "$BACKEND_DIR/vendor" "$FRONTEND_DIR/"
|
||||
|
||||
# VERIFY vendor/ was copied successfully
|
||||
if [ ! -f "$FRONTEND_DIR/vendor/autoload.php" ]; then
|
||||
print_error "Failed to copy vendor/ to frontend!"
|
||||
print_info "Check permissions and disk space"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_success "Composer dependencies copied and verified"
|
||||
print_success "Frontend files copied"
|
||||
|
||||
# Handle .env file for frontend
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue