-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-build.sh
More file actions
executable file
·44 lines (37 loc) · 1.45 KB
/
docker-build.sh
File metadata and controls
executable file
·44 lines (37 loc) · 1.45 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
#!/bin/bash
# Docker build script with retry logic for network issues
echo "🐳 Building OpsAI Docker container with retry logic..."
MAX_ATTEMPTS=3
ATTEMPT=1
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
echo "🔄 Attempt $ATTEMPT of $MAX_ATTEMPTS"
if docker-compose build --no-cache; then
echo "✅ Build successful!"
echo "🚀 Starting containers..."
docker-compose up
exit 0
else
echo "❌ Build failed on attempt $ATTEMPT"
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
echo "💥 All attempts failed. Trying with minimal requirements..."
# Backup original requirements
cp requirements.txt requirements-full.txt
cp requirements-minimal.txt requirements.txt
echo "📦 Building with minimal requirements..."
if docker-compose build --no-cache; then
echo "✅ Minimal build successful!"
echo "ℹ️ You can install additional packages later if needed"
docker-compose up
exit 0
else
echo "💥 Even minimal build failed. Check your network connection."
# Restore original requirements
cp requirements-full.txt requirements.txt
exit 1
fi
fi
echo "⏳ Waiting 10 seconds before retry..."
sleep 10
ATTEMPT=$((ATTEMPT + 1))
fi
done