-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathrun_docker.sh
More file actions
executable file
·172 lines (145 loc) · 3.92 KB
/
Copy pathrun_docker.sh
File metadata and controls
executable file
·172 lines (145 loc) · 3.92 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/bash
# EasyMD Docker Helper Script
# This script helps you build and run EasyMD in Docker containers
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if Docker is installed
check_docker() {
if ! command -v docker &> /dev/null; then
print_error "Docker is not installed. Please install Docker first."
exit 1
fi
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
setup_directories() {
print_info "Setting up directories..."
mkdir -p outputs logs
chmod 755 outputs logs
}
# Build Docker image
build() {
print_info "Building EasyMD Docker image..."
docker-compose build easy-md
print_info "Build completed successfully!"
}
# Run a simple test
test_run() {
print_info "Running a test simulation..."
setup_directories
# Start container
docker-compose up -d easy-md
# Run test simulation
docker-compose exec easy-md easy-md /app/inputs/4W52.pdb --ligand_file /app/inputs/4w52_C_EPE.sdf --nsteps 100
print_info "Test completed! Check the outputs directory for results."
}
# Start interactive session
interactive() {
print_info "Starting interactive session..."
setup_directories
docker-compose up -d easy-md
docker-compose exec easy-md bash
}
# Start Jupyter notebook
jupyter() {
print_info "Starting Jupyter notebook..."
setup_directories
docker-compose up -d easy-md-jupyter
print_info "Jupyter notebook is available at: http://localhost:8888"
}
# Start GPU container
gpu() {
print_info "Starting GPU container..."
setup_directories
# Check if nvidia-docker is available
if ! docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi &> /dev/null; then
print_warning "NVIDIA Docker runtime not detected. GPU acceleration may not work."
fi
docker-compose up -d easy-md-gpu
print_info "GPU container started. You can now run GPU-accelerated simulations."
}
# Clean up
cleanup() {
print_info "Cleaning up Docker resources..."
docker-compose down -v
docker rmi easy-md 2>/dev/null || true
print_info "Cleanup completed!"
}
# Show usage
usage() {
cat << EOF
EasyMD Docker Helper Script
Usage: $0 [COMMAND]
Commands:
build Build the Docker image
test Run a test simulation
interactive Start interactive session
jupyter Start Jupyter notebook server
gpu Start GPU-enabled container
cleanup Clean up Docker resources
help Show this help message
Examples:
$0 build # Build the image
$0 test # Run a quick test
$0 interactive # Start interactive session
$0 jupyter # Start Jupyter notebook
$0 gpu # Start GPU container
For more detailed usage, see DOCKER_README.md
EOF
}
# Main script logic
main() {
case "${1:-help}" in
build)
check_docker
build
;;
test)
check_docker
test_run
;;
interactive)
check_docker
interactive
;;
jupyter)
check_docker
jupyter
;;
gpu)
check_docker
gpu
;;
cleanup)
check_docker
cleanup
;;
help|--help|-h)
usage
;;
*)
print_error "Unknown command: $1"
usage
exit 1
;;
esac
}
# Run main function
main "$@"