Complete Next.js website with Docker containerization: - Next.js 14 with TypeScript and Tailwind CSS - Responsive design with modern UI components - Hero section, features showcase, testimonials - FAQ section with comprehensive content - Contact forms and newsletter signup - Docker production build with Nginx - Health checks and monitoring support - SEO optimization and performance tuning Ready for integration as git submodule in main CHORUS project. Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
284 lines
7.7 KiB
Bash
Executable File
284 lines
7.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# CHORUS Services Website - Docker Development Helper
|
|
# Provides convenient commands for Docker operations
|
|
|
|
set -e
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Print colored output
|
|
print_info() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
print_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Show usage information
|
|
show_help() {
|
|
echo "CHORUS Website Docker Helper"
|
|
echo ""
|
|
echo "Usage: $0 [COMMAND]"
|
|
echo ""
|
|
echo "Development Commands:"
|
|
echo " dev Start development environment"
|
|
echo " dev-full Start development with all services (cache, db, email)"
|
|
echo " dev-stop Stop development environment"
|
|
echo " dev-clean Clean up development containers and volumes"
|
|
echo ""
|
|
echo "Production Commands:"
|
|
echo " build Build production Docker image"
|
|
echo " test-prod Test production image locally"
|
|
echo " push Build and push to registry"
|
|
echo " deploy Deploy to production swarm"
|
|
echo ""
|
|
echo "Utility Commands:"
|
|
echo " logs Show container logs"
|
|
echo " shell Open shell in running container"
|
|
echo " health Check container health"
|
|
echo " clean Clean up all Docker resources"
|
|
echo " status Show status of all services"
|
|
echo ""
|
|
echo "Help:"
|
|
echo " help Show this help message"
|
|
}
|
|
|
|
# Start development environment
|
|
dev_start() {
|
|
print_info "Starting CHORUS website development environment..."
|
|
docker-compose up -d website-dev
|
|
print_success "Development environment started"
|
|
print_info "Website available at: http://localhost:3000"
|
|
}
|
|
|
|
# Start full development environment
|
|
dev_start_full() {
|
|
print_info "Starting full development environment with all services..."
|
|
docker-compose --profile cache --profile database --profile email up -d
|
|
print_success "Full development environment started"
|
|
print_info "Services available:"
|
|
echo " - Website: http://localhost:3000"
|
|
echo " - Mailhog: http://localhost:8025"
|
|
echo " - Redis: localhost:6379"
|
|
echo " - PostgreSQL: localhost:5432"
|
|
}
|
|
|
|
# Stop development environment
|
|
dev_stop() {
|
|
print_info "Stopping development environment..."
|
|
docker-compose down
|
|
print_success "Development environment stopped"
|
|
}
|
|
|
|
# Clean development environment
|
|
dev_clean() {
|
|
print_warning "This will remove all containers, networks, and volumes"
|
|
read -p "Are you sure? (y/N) " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
docker-compose down -v --remove-orphans
|
|
docker system prune -f
|
|
print_success "Development environment cleaned"
|
|
else
|
|
print_info "Cancelled"
|
|
fi
|
|
}
|
|
|
|
# Build production image
|
|
build_production() {
|
|
print_info "Building production Docker image..."
|
|
docker build -t chorus-website:latest .
|
|
print_success "Production image built successfully"
|
|
}
|
|
|
|
# Test production image locally
|
|
test_production() {
|
|
print_info "Testing production image locally..."
|
|
|
|
# Stop any existing container
|
|
docker stop chorus-website-test 2>/dev/null || true
|
|
docker rm chorus-website-test 2>/dev/null || true
|
|
|
|
# Start production container
|
|
docker run -d --name chorus-website-test -p 8080:80 chorus-website:latest
|
|
|
|
# Wait for container to start
|
|
sleep 5
|
|
|
|
# Test health check
|
|
if curl -f http://localhost:8080/ > /dev/null 2>&1; then
|
|
print_success "Production image test passed"
|
|
print_info "Website available at: http://localhost:8080"
|
|
print_info "Stop test container with: docker stop chorus-website-test"
|
|
else
|
|
print_error "Production image test failed"
|
|
docker logs chorus-website-test
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Push to registry
|
|
push_to_registry() {
|
|
print_info "Building and pushing to registry..."
|
|
cd .. && ./build-and-push.sh website
|
|
print_success "Image pushed to registry"
|
|
}
|
|
|
|
# Deploy to production
|
|
deploy_production() {
|
|
print_info "Deploying to production swarm..."
|
|
cd ..
|
|
docker service update chorus_chorus-website --image registry.home.deepblack.cloud/tony/chorus-website:latest --force
|
|
print_success "Deployment initiated"
|
|
print_info "Check deployment status with: docker service ps chorus_chorus-website"
|
|
}
|
|
|
|
# Show logs
|
|
show_logs() {
|
|
local service=${1:-website-dev}
|
|
print_info "Showing logs for $service..."
|
|
docker-compose logs -f $service
|
|
}
|
|
|
|
# Open shell in container
|
|
open_shell() {
|
|
local service=${1:-website-dev}
|
|
print_info "Opening shell in $service..."
|
|
docker-compose exec $service sh
|
|
}
|
|
|
|
# Check health
|
|
check_health() {
|
|
print_info "Checking container health..."
|
|
|
|
# Check development container
|
|
if docker-compose ps website-dev | grep -q "Up"; then
|
|
print_success "Development container is running"
|
|
if curl -f http://localhost:3000/ > /dev/null 2>&1; then
|
|
print_success "Development website is healthy"
|
|
else
|
|
print_error "Development website is not responding"
|
|
fi
|
|
else
|
|
print_warning "Development container is not running"
|
|
fi
|
|
|
|
# Check production test container
|
|
if docker ps | grep -q "chorus-website-test"; then
|
|
print_success "Production test container is running"
|
|
if curl -f http://localhost:8080/ > /dev/null 2>&1; then
|
|
print_success "Production test website is healthy"
|
|
else
|
|
print_error "Production test website is not responding"
|
|
fi
|
|
else
|
|
print_warning "Production test container is not running"
|
|
fi
|
|
}
|
|
|
|
# Clean up all Docker resources
|
|
clean_all() {
|
|
print_warning "This will remove all Docker containers, images, and volumes for this project"
|
|
read -p "Are you sure? (y/N) " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
print_info "Stopping containers..."
|
|
docker-compose down -v --remove-orphans
|
|
|
|
print_info "Removing images..."
|
|
docker rmi chorus-website:latest 2>/dev/null || true
|
|
docker rmi chorus-website-dev:latest 2>/dev/null || true
|
|
|
|
print_info "Cleaning system..."
|
|
docker system prune -f
|
|
|
|
print_success "All resources cleaned"
|
|
else
|
|
print_info "Cancelled"
|
|
fi
|
|
}
|
|
|
|
# Show status
|
|
show_status() {
|
|
print_info "CHORUS Website Docker Status"
|
|
echo "================================"
|
|
|
|
echo -e "\n${BLUE}Development Environment:${NC}"
|
|
docker-compose ps
|
|
|
|
echo -e "\n${BLUE}Production Test:${NC}"
|
|
docker ps --filter "name=chorus-website-test" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
|
|
|
|
echo -e "\n${BLUE}Docker Images:${NC}"
|
|
docker images | grep -E "(chorus-website|REPOSITORY)"
|
|
|
|
echo -e "\n${BLUE}Docker System:${NC}"
|
|
docker system df
|
|
}
|
|
|
|
# Main command handling
|
|
case "${1:-}" in
|
|
"dev")
|
|
dev_start
|
|
;;
|
|
"dev-full")
|
|
dev_start_full
|
|
;;
|
|
"dev-stop")
|
|
dev_stop
|
|
;;
|
|
"dev-clean")
|
|
dev_clean
|
|
;;
|
|
"build")
|
|
build_production
|
|
;;
|
|
"test-prod")
|
|
test_production
|
|
;;
|
|
"push")
|
|
push_to_registry
|
|
;;
|
|
"deploy")
|
|
deploy_production
|
|
;;
|
|
"logs")
|
|
show_logs $2
|
|
;;
|
|
"shell")
|
|
open_shell $2
|
|
;;
|
|
"health")
|
|
check_health
|
|
;;
|
|
"clean")
|
|
clean_all
|
|
;;
|
|
"status")
|
|
show_status
|
|
;;
|
|
"help"|"-h"|"--help"|"")
|
|
show_help
|
|
;;
|
|
*)
|
|
print_error "Unknown command: $1"
|
|
echo ""
|
|
show_help
|
|
exit 1
|
|
;;
|
|
esac |