-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
99 lines (84 loc) · 2.88 KB
/
Copy pathbuild.sh
File metadata and controls
99 lines (84 loc) · 2.88 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
#!/bin/bash
echo "=========================================="
echo "🔨 Building All Docker Containers"
echo "=========================================="
echo ""
# Culori pentru output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function pentru build cu verificare
build_container() {
local container_name=$1
local folder=$2
echo ""
echo "================================================"
echo -e "${YELLOW}📦 Building: $container_name${NC}"
echo "================================================"
cd "$folder" || exit
# Verifică dacă există Dockerfile
if [ ! -f "Dockerfile" ]; then
echo -e "${RED}❌ Dockerfile not found in $folder${NC}"
cd ..
return 1
fi
# Build cu Maven dacă există pom.xml
if [ -f "pom.xml" ]; then
echo "📦 Building with Maven..."
mvn clean package -DskipTests
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Maven build failed for $container_name${NC}"
cd ..
return 1
fi
fi
# Build cu npm dacă există package.json
if [ -f "package.json" ]; then
echo "📦 Installing npm dependencies..."
npm install
if [ $? -ne 0 ]; then
echo -e "${RED}❌ npm install failed for $container_name${NC}"
cd ..
return 1
fi
fi
cd ..
echo -e "${GREEN}✅ $container_name built successfully${NC}"
}
# Start time
start_time=$(date +%s)
# Build individual containers (dacă vrei să compilezi cu Maven/npm înainte)
build_container "Container 01 - Javalin" "container01-javalin"
build_container "Container 03 - EJB MDB" "container03-ejb-mdb"
build_container "Container 04 - RMI Zoom In" "container04-rmi-server-zoomin"
build_container "Container 05 - RMI Zoom Out" "container05-rmi-server-zoomout"
build_container "Container 06 - Node.js" "container06-nodejs-db"
echo ""
echo "================================================"
echo -e "${YELLOW}🐳 Building Docker Images with Docker Compose${NC}"
echo "================================================"
echo ""
# Build all Docker images
docker-compose build --no-cache
if [ $? -eq 0 ]; then
end_time=$(date +%s)
duration=$((end_time - start_time))
echo ""
echo "=========================================="
echo -e "${GREEN}✅ All containers built successfully!${NC}"
echo "=========================================="
echo "⏱️ Total build time: ${duration}s"
echo ""
echo "📋 Next steps:"
echo " ./run.sh - Start all containers"
echo " ./stop.sh - Stop all containers"
echo " ./clean.sh - Clean up everything"
echo ""
else
echo ""
echo "=========================================="
echo -e "${RED}❌ Docker build failed${NC}"
echo "=========================================="
exit 1
fi