112 lines
2.9 KiB
Bash
112 lines
2.9 KiB
Bash
#!/bin/bash
|
|
|
|
# Deployment script for market data infrastructure
|
|
# Run this on your Docker host at 192.168.0.10
|
|
|
|
set -e
|
|
|
|
echo "🚀 Deploying Market Data Infrastructure..."
|
|
|
|
# Check if Docker and Docker Compose are available
|
|
if ! command -v docker &> /dev/null; then
|
|
echo "❌ Docker is not installed or not in PATH"
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
|
|
echo "❌ Docker Compose is not installed or not in PATH"
|
|
exit 1
|
|
fi
|
|
|
|
# Set Docker Compose command
|
|
if docker compose version &> /dev/null; then
|
|
DOCKER_COMPOSE="docker compose"
|
|
else
|
|
DOCKER_COMPOSE="docker-compose"
|
|
fi
|
|
|
|
# Create necessary directories
|
|
echo "📁 Creating directories..."
|
|
mkdir -p ./data/timescale
|
|
mkdir -p ./data/redis
|
|
mkdir -p ./logs
|
|
mkdir -p ./backups
|
|
|
|
# Set proper permissions
|
|
echo "🔐 Setting permissions..."
|
|
chmod 755 ./data/timescale
|
|
chmod 755 ./data/redis
|
|
chmod 755 ./logs
|
|
chmod 755 ./backups
|
|
|
|
# Copy environment file if it doesn't exist
|
|
if [ ! -f .env ]; then
|
|
echo "📋 Creating .env file..."
|
|
cp .env.example .env
|
|
echo "⚠️ Please edit .env file with your specific configuration"
|
|
echo "⚠️ Default passwords are set - change them for production!"
|
|
fi
|
|
|
|
# Pull latest images
|
|
echo "📥 Pulling Docker images..."
|
|
$DOCKER_COMPOSE -f timescaledb-compose.yml pull
|
|
|
|
# Stop existing containers if running
|
|
echo "🛑 Stopping existing containers..."
|
|
$DOCKER_COMPOSE -f timescaledb-compose.yml down
|
|
|
|
# Start the services
|
|
echo "🏃 Starting services..."
|
|
$DOCKER_COMPOSE -f timescaledb-compose.yml up -d
|
|
|
|
# Wait for services to be ready
|
|
echo "⏳ Waiting for services to be ready..."
|
|
sleep 30
|
|
|
|
# Check service health
|
|
echo "🏥 Checking service health..."
|
|
|
|
# Check TimescaleDB
|
|
if docker exec market_data_timescaledb pg_isready -U market_user -d market_data; then
|
|
echo "✅ TimescaleDB is ready"
|
|
else
|
|
echo "❌ TimescaleDB is not ready"
|
|
exit 1
|
|
fi
|
|
|
|
# Check Redis
|
|
if docker exec market_data_redis redis-cli -a market_data_redis_2024 ping | grep -q PONG; then
|
|
echo "✅ Redis is ready"
|
|
else
|
|
echo "❌ Redis is not ready"
|
|
exit 1
|
|
fi
|
|
|
|
# Display connection information
|
|
echo ""
|
|
echo "🎉 Deployment completed successfully!"
|
|
echo ""
|
|
echo "📊 Connection Information:"
|
|
echo " TimescaleDB:"
|
|
echo " Host: 192.168.0.10"
|
|
echo " Port: 5432"
|
|
echo " Database: market_data"
|
|
echo " Username: market_user"
|
|
echo " Password: (check .env file)"
|
|
echo ""
|
|
echo " Redis:"
|
|
echo " Host: 192.168.0.10"
|
|
echo " Port: 6379"
|
|
echo " Password: (check .env file)"
|
|
echo ""
|
|
echo "📝 Next steps:"
|
|
echo " 1. Update your application configuration to use these connection details"
|
|
echo " 2. Test the connection from your application"
|
|
echo " 3. Set up monitoring and alerting"
|
|
echo " 4. Configure backup schedules"
|
|
echo ""
|
|
echo "🔍 To view logs:"
|
|
echo " docker-compose -f timescaledb-compose.yml logs -f"
|
|
echo ""
|
|
echo "🛑 To stop services:"
|
|
echo " docker-compose -f timescaledb-compose.yml down" |