File size: 2,211 Bytes
aa15bce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# OpenPoke Deployment Script
echo "πŸš€ Deploying OpenPoke with FriendliAI integration..."

# Check if .env file exists
if [ ! -f ".env" ]; then
    echo "⚠️  Warning: .env file not found!"
    echo "πŸ“ Please copy .env.example to .env and configure your API keys:"
    echo "   cp .env.example .env"
    echo "   # Then edit .env with your actual credentials"
    echo ""
    echo "πŸ”„ Continuing with default configuration (you may need to configure API keys manually)..."
fi

# Check if Docker is installed
if ! command -v docker &> /dev/null; then
    echo "❌ Docker is not installed. Please install Docker first."
    exit 1
fi

# Check if docker-compose is installed
if command -v docker-compose &> /dev/null; then
    COMPOSE_CMD="docker-compose"
elif docker compose version &> /dev/null; then
    COMPOSE_CMD="docker compose"
else
    echo "❌ docker-compose is not installed. Please install docker-compose (or enable the Docker Compose plugin) first."
    exit 1
fi

# Stop any existing containers
echo "πŸ›‘ Stopping existing containers..."
${COMPOSE_CMD} down

# Build and start the services
echo "πŸ”¨ Building and starting services..."
if [ -f ".env" ]; then
    ${COMPOSE_CMD} --env-file .env up --build -d
else
    ${COMPOSE_CMD} up --build -d
fi

# Wait for services to be ready
echo "⏳ Waiting for services to start..."
sleep 15

# Check if services are running
if ${COMPOSE_CMD} ps | grep -q "Up"; then
    echo "βœ… Deployment successful!"
    echo ""
    echo "🌐 Services are running:"
    echo "   - Server API: http://localhost:8001"
    echo "   - Web UI: http://localhost:3000"
    echo ""
    echo "πŸ“– Check the logs with: ${COMPOSE_CMD} logs -f"
    echo "πŸ” View service status: ${COMPOSE_CMD} ps"
    echo "πŸ›‘ Stop with: ${COMPOSE_CMD} down"
    echo ""
    echo "πŸ’‘ Tip: If you encounter API key issues, edit your .env file with correct credentials"
else
    echo "❌ Deployment failed. Check the logs with: ${COMPOSE_CMD} logs"
    echo ""
    echo "πŸ”§ Troubleshooting tips:"
    echo "   1. Check if your .env file has valid API keys"
    echo "   2. Verify Docker has enough resources"
    echo "   3. Check firewall settings"
    exit 1
fi