-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_docker.sh
More file actions
executable file
·78 lines (64 loc) · 2.88 KB
/
setup_docker.sh
File metadata and controls
executable file
·78 lines (64 loc) · 2.88 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
#!/bin/bash
# Setup script to build and run the ecommerce microservice in Docker
# This script should be run from the gilhari_ecommerce directory
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ECOMMERCE_DIR="$SCRIPT_DIR/../ormcp_server/v2_ormcp_server-0.4.3/gilhari_ecommerce"
echo "🚀 Setting up Ecommerce Microservice in Docker"
echo "=============================================="
# Check if we're in the right directory or need to navigate
if [ ! -f "$ECOMMERCE_DIR/Dockerfile" ]; then
echo "❌ Error: Cannot find gilhari_ecommerce directory"
echo " Expected at: $ECOMMERCE_DIR"
exit 1
fi
cd "$ECOMMERCE_DIR"
# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
echo "❌ Error: Docker is not running. Please start Docker and try again."
exit 1
fi
# Check if PostgreSQL is accessible
echo "🔍 Checking PostgreSQL connection..."
if ! psql -h localhost -p 5432 -U postgres -d ecommerce -c "SELECT 1;" > /dev/null 2>&1; then
echo "⚠️ Warning: Cannot connect to PostgreSQL at localhost:5432"
echo " Please ensure PostgreSQL is running and the 'ecommerce' database exists"
echo " You may need to create the database:"
echo " createdb -h localhost -p 5432 -U postgres ecommerce"
fi
# Build the Docker image
echo "🐳 Building Docker image..."
docker build -t gilhari_ecommerce:1.0 .
# Stop and remove existing container if it exists
echo "🔄 Stopping existing container (if any)..."
docker stop gilhari_ecommerce_container 2>/dev/null || echo " No existing container to stop"
docker rm gilhari_ecommerce_container 2>/dev/null || echo " No existing container to remove"
# Run the container
echo "🚀 Starting new container..."
docker run -d --name gilhari_ecommerce_container -p 8081:8081 gilhari_ecommerce:1.0
# Wait for service to start
echo "⏳ Waiting for service to start..."
sleep 8
# Test the service
echo "🧪 Testing microservice..."
if curl -s http://localhost:8081/gilhari/v1/getObjectModelSummary/now > /dev/null; then
echo ""
echo "✅ Ecommerce Microservice is running successfully!"
echo "================================================"
echo "🌐 Service URL: http://localhost:8081/gilhari/v1/"
echo "🐳 Container: gilhari_ecommerce_container"
echo "📊 Object Model: http://localhost:8081/gilhari/v1/getObjectModelSummary/now"
echo ""
echo "📝 Next steps:"
echo " 1. Start the ORMCP server:"
echo " export GILHARI_BASE_URL='http://localhost:8081/gilhari/v1/'"
echo " export MCP_SERVER_NAME='InventoryWatchdog'"
echo " ormcp-server --mode http --port 8080"
echo ""
echo " 2. Run the inventory agent:"
echo " python inventory_agent.py --openai-api-key YOUR_KEY --ormcp-url http://localhost:8080"
else
echo "❌ Microservice failed to start. Check logs:"
echo " docker logs gilhari_ecommerce_container"
exit 1
fi