Some checks are pending
Deploy to Production / deploy (push) Waiting to run
- Changed admin frontend port from 3000 to 3300 across all configuration files - Changed API backend port from 3001 to 3301 across all configuration files - Updated health check endpoints to use new ports in CI/CD workflow - Modified documentation and deployment guides to reflect new port numbers - Updated Caddy and Nginx reverse proxy configurations to use new ports
81 lines
2.1 KiB
Bash
Executable File
81 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
echo "🚀 VoxBlog Deployment Script"
|
|
echo "=============================="
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Check if .env exists
|
|
if [ ! -f .env ]; then
|
|
echo -e "${RED}❌ .env file not found!${NC}"
|
|
echo "Please create .env file from .env.example"
|
|
exit 1
|
|
fi
|
|
|
|
# Pull latest code
|
|
echo -e "${YELLOW}📥 Pulling latest code...${NC}"
|
|
git pull origin main
|
|
|
|
# Stop existing containers
|
|
echo -e "${YELLOW}🛑 Stopping existing containers...${NC}"
|
|
docker-compose down
|
|
|
|
# Build new images
|
|
echo -e "${YELLOW}🔨 Building new images...${NC}"
|
|
docker-compose build --no-cache
|
|
|
|
# Start containers
|
|
echo -e "${YELLOW}▶️ Starting containers...${NC}"
|
|
docker-compose up -d
|
|
|
|
# Wait for services to be ready
|
|
echo -e "${YELLOW}⏳ Waiting for services to start...${NC}"
|
|
sleep 15
|
|
|
|
# Run database migrations
|
|
echo -e "${YELLOW}🗄️ Running database migrations...${NC}"
|
|
docker-compose exec -T api pnpm run drizzle:migrate || echo "Migration skipped or failed"
|
|
|
|
# Health check
|
|
echo -e "${YELLOW}🏥 Performing health checks...${NC}"
|
|
|
|
API_HEALTH=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3301/api/health || echo "000")
|
|
if [ "$API_HEALTH" = "200" ]; then
|
|
echo -e "${GREEN}✅ API is healthy${NC}"
|
|
else
|
|
echo -e "${RED}❌ API health check failed (HTTP $API_HEALTH)${NC}"
|
|
echo "Checking API logs:"
|
|
docker-compose logs --tail=50 api
|
|
exit 1
|
|
fi
|
|
|
|
ADMIN_HEALTH=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3300 || echo "000")
|
|
if [ "$ADMIN_HEALTH" = "200" ]; then
|
|
echo -e "${GREEN}✅ Admin is healthy${NC}"
|
|
else
|
|
echo -e "${RED}❌ Admin health check failed (HTTP $ADMIN_HEALTH)${NC}"
|
|
echo "Checking Admin logs:"
|
|
docker-compose logs --tail=50 admin
|
|
exit 1
|
|
fi
|
|
|
|
# Clean up old images
|
|
echo -e "${YELLOW}🧹 Cleaning up old Docker images...${NC}"
|
|
docker image prune -af --filter "until=24h"
|
|
|
|
echo ""
|
|
echo -e "${GREEN}✅ Deployment complete!${NC}"
|
|
echo ""
|
|
echo "Services running:"
|
|
echo " - API: http://localhost:3301"
|
|
echo " - Admin: http://localhost:3300"
|
|
echo ""
|
|
echo "To view logs: docker-compose logs -f"
|
|
echo "To stop: docker-compose down"
|