File size: 2,668 Bytes
7f8c6a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Docker build and run script for CMPE343 Competition

#!/bin/bash
set -e

echo "🐳 CMPE343 Competition Docker Setup"
echo "=================================="

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Function to print colored output
print_status() {
    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"
}

# Check if Docker is installed
if ! command -v docker &> /dev/null; then
    print_error "Docker is not installed. Please install Docker first."
    exit 1
fi

# Check if Docker Compose is installed
if ! command -v docker-compose &> /dev/null; then
    print_error "Docker Compose is not installed. Please install Docker Compose first."
    exit 1
fi

# Create necessary directories
print_status "Creating necessary directories..."
mkdir -p state anonymized_teams monitoring

# Make entrypoint script executable
chmod +x docker-entrypoint.sh

# Build the Docker image
print_status "Building Docker image..."
docker build -t cmpe343-competition .

if [ $? -eq 0 ]; then
    print_success "Docker image built successfully!"
else
    print_error "Failed to build Docker image"
    exit 1
fi

# Check if we should run with docker-compose
if [ "$1" = "--compose" ]; then
    print_status "Starting with Docker Compose..."
    docker-compose up -d
    
    if [ $? -eq 0 ]; then
        print_success "Competition is running!"
        print_status "Access the application at: http://localhost:7860"
        print_status "To view logs: docker-compose logs -f"
        print_status "To stop: docker-compose down"
    else
        print_error "Failed to start with Docker Compose"
        exit 1
    fi
else
    # Run with regular docker command
    print_status "Starting competition container..."
    docker run -d \
        --name cmpe343-competition \
        -p 7860:7860 \
        -v "$(pwd)/state:/app/state" \
        -v "$(pwd)/anonymized_teams:/app/anonymized_teams" \
        -v "$(pwd)/models.yaml:/app/models.yaml" \
        -v "$(pwd)/tracks.csv:/app/tracks.csv" \
        cmpe343-competition
    
    if [ $? -eq 0 ]; then
        print_success "Competition is running!"
        print_status "Access the application at: http://localhost:7860"
        print_status "To view logs: docker logs -f cmpe343-competition"
        print_status "To stop: docker stop cmpe343-competition"
    else
        print_error "Failed to start competition container"
        exit 1
    fi
fi

print_success "Setup complete! 🎉"