#!/bin/bash set -e echo "=== Divar Crawler Production Deployment Script ===" # Check if docker is installed if ! command -v docker &> /dev/null; then echo "Error: docker is not installed. Please install Docker and Docker Compose." exit 1 fi # Create .env from .env.example if missing if [ ! -f .env ]; then echo "Creating .env from .env.example..." cp .env.example .env echo "WARNING: Please edit .env and set your OPENAI_API_KEY and passwords before running!" fi # Source .env if exists to read HTTP_PORT if [ -f .env ]; then export $(grep -v '^#' .env | xargs) fi PORT="${HTTP_PORT:-8080}" echo "Pulling latest code changes..." git pull origin master || true echo "Building and launching containers..." docker compose down || true docker compose up -d --build echo "Checking container statuses..." docker compose ps echo "=== Deployment Successful! ===" echo "Access the application at http://localhost:${PORT} or http://YOUR_SERVER_IP:${PORT}"