-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-setup.sh
More file actions
executable file
·131 lines (109 loc) · 3.58 KB
/
Copy pathdocker-setup.sh
File metadata and controls
executable file
·131 lines (109 loc) · 3.58 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
# BioAnalyzer Package Docker Setup Script
set -e
echo "🐳 BioAnalyzer Package 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_warning "Docker Compose not found. Using docker compose instead."
COMPOSE_CMD="docker compose"
else
COMPOSE_CMD="docker-compose"
fi
print_status "Cleaning up existing containers and images..."
# Stop and remove existing containers
docker stop $(docker ps -aq --filter "name=bioanalyzer") 2>/dev/null || true
docker rm $(docker ps -aq --filter "name=bioanalyzer") 2>/dev/null || true
# Remove existing images
docker rmi bioanalyzer-package 2>/dev/null || true
print_status "Building BioAnalyzer Package Docker image..."
# Build the Docker image
docker build -t bioanalyzer-package .
if [ $? -eq 0 ]; then
print_success "Docker image built successfully!"
else
print_error "Failed to build Docker image"
exit 1
fi
print_status "Testing Docker image..."
# Test the image with a simple command
docker run --rm bioanalyzer-package python scripts/dev/cli_smoke_check.py
if [ $? -eq 0 ]; then
print_success "Docker image test passed!"
else
print_warning "Docker image test had issues, but continuing..."
fi
echo ""
echo "🚀 Docker Setup Complete!"
echo "========================"
echo ""
echo "Available commands:"
echo ""
echo "1. Start API Server:"
echo " docker run -d --name bioanalyzer-api -p 8000:8000 bioanalyzer-package"
echo ""
echo "2. Use CLI (interactive):"
echo " docker run -it --rm bioanalyzer-package python scripts/cli.py fields"
echo " docker run -it --rm bioanalyzer-package python scripts/cli.py analyze 12345678"
echo ""
echo "3. Use CLI with custom command:"
echo " docker run --rm bioanalyzer-package python scripts/cli.py analyze --help"
echo ""
echo "4. Start with Docker Compose:"
echo " $COMPOSE_CMD up -d"
echo ""
echo "5. View logs:"
echo " docker logs bioanalyzer-api"
echo ""
echo "6. Stop and remove:"
echo " docker stop bioanalyzer-api && docker rm bioanalyzer-api"
echo ""
# Ask if user wants to start the container
read -p "Would you like to start the API server now? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
print_status "Starting BioAnalyzer Package API server..."
docker run -d --name bioanalyzer-api -p 8000:8000 bioanalyzer-package
if [ $? -eq 0 ]; then
print_success "API server started successfully!"
echo ""
API_URL="${BIOANALYZER_API_URL:-http://localhost:8000}"
# If user set BIOANALYZER_API_URL to include /api/v1, strip it for root endpoints.
API_ROOT="${API_URL%/}"
API_ROOT="${API_ROOT%/api/v1}"
echo "🌐 API available at: ${API_ROOT}"
echo "📚 Documentation: ${API_ROOT}/docs"
echo "🔍 Health check: ${API_ROOT}/health"
echo ""
echo "To view logs: docker logs bioanalyzer-api"
echo "To stop: docker stop bioanalyzer-api"
else
print_error "Failed to start API server"
exit 1
fi
fi
print_success "Setup complete! 🎉"