1 #!/bin/bash
2 3 # Test the deployment script using Docker
4 # This script builds a Docker image and runs the deployment tests
5 6 set -e
7 8 # Colors for output
9 RED='\033[0;31m'
10 GREEN='\033[0;32m'
11 YELLOW='\033[1;33m'
12 BLUE='\033[0;34m'
13 NC='\033[0m' # No Color
14 15 echo -e "${BLUE}=== ORLY Deployment Script Docker Test ===${NC}"
16 echo ""
17 18 # Check if Docker is available
19 if ! command -v docker >/dev/null 2>&1; then
20 echo -e "${RED}ERROR: Docker is not installed or not in PATH${NC}"
21 echo "Please install Docker to run this test."
22 echo ""
23 echo "Alternative: Run the local test instead:"
24 echo " ./test-deploy-local.sh"
25 exit 1
26 fi
27 28 # Check if Docker is accessible
29 if ! docker info >/dev/null 2>&1; then
30 echo -e "${RED}ERROR: Cannot access Docker daemon${NC}"
31 echo "This usually means:"
32 echo " 1. Docker daemon is not running"
33 echo " 2. Current user is not in the 'docker' group"
34 echo " 3. Need to run with sudo"
35 echo ""
36 echo "Try one of these solutions:"
37 echo " sudo ./test-deploy-docker.sh"
38 echo " sudo usermod -aG docker \$USER && newgrp docker"
39 echo ""
40 echo "Alternative: Run the local test instead:"
41 echo " ./test-deploy-local.sh"
42 exit 1
43 fi
44 45 # Check if we're in the right directory
46 if [[ ! -f "go.mod" ]] || ! grep -q "next.orly.dev" go.mod; then
47 echo -e "${RED}ERROR: This script must be run from the next.orly.dev project root${NC}"
48 exit 1
49 fi
50 51 echo -e "${YELLOW}Building Docker test image...${NC}"
52 docker build -f scripts/Dockerfile.deploy-test -t orly-deploy-test . || {
53 echo -e "${RED}ERROR: Failed to build Docker test image${NC}"
54 exit 1
55 }
56 57 echo ""
58 echo -e "${YELLOW}Running deployment tests...${NC}"
59 echo ""
60 61 # Run the container and capture the exit code
62 if docker run --rm orly-deploy-test; then
63 echo ""
64 echo -e "${GREEN}✅ All deployment tests passed successfully!${NC}"
65 echo ""
66 echo -e "${BLUE}The deployment script is ready for use.${NC}"
67 echo ""
68 echo "To deploy ORLY on a server:"
69 echo " 1. Clone the repository"
70 echo " 2. Run: ./scripts/deploy.sh"
71 echo " 3. Configure environment variables"
72 echo " 4. Start the service: sudo systemctl start orly"
73 echo ""
74 else
75 echo ""
76 echo -e "${RED}❌ Deployment tests failed!${NC}"
77 echo ""
78 echo "Please check the output above for specific errors."
79 exit 1
80 fi
81 82 # Clean up the test image
83 echo -e "${YELLOW}Cleaning up test image...${NC}"
84 docker rmi orly-deploy-test >/dev/null 2>&1 || true
85 86 echo -e "${GREEN}Test completed successfully!${NC}"
87