forked from higress-group/himarket
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
55 lines (47 loc) · 1.23 KB
/
build.sh
File metadata and controls
55 lines (47 loc) · 1.23 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
#!/bin/bash
VERSION=latest
set -e
# 检查 Java 版本
JAVA_VERSION_OUTPUT=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2)
JAVA_MAJOR=$(echo "$JAVA_VERSION_OUTPUT" | cut -d'.' -f1)
if [ "$JAVA_MAJOR" = "1" ]; then
JAVA_MAJOR=$(echo "$JAVA_VERSION_OUTPUT" | cut -d'.' -f2)
fi
if [ "$JAVA_MAJOR" != "17" ]; then
echo "❌ Error: Java 17 is required, but found Java $JAVA_VERSION_OUTPUT"
exit 1
fi
echo "✅ Java 17 detected."
# 构建 server
echo "=== Building backend server ==="
echo "Building with Maven..."
mvn clean package -DskipTests
cd himarket-bootstrap
echo "Building backend Docker image..."
docker buildx build \
--platform linux/amd64 \
-t himarket-server:$VERSION \
--load .
echo "Backend server build completed"
cd ..
# 构建 frontend
cd himarket-web/himarket-frontend
echo "=== Building frontend ==="
rm -rf ./dist
npm install --force
npm run build
docker buildx build \
-t himarket-frontend:$VERSION \
--platform linux/amd64 \
--load .
# 构建 admin
cd ../himarket-admin
echo "=== Building admin ==="
rm -rf ./dist
npm install --force
npm run build
docker buildx build \
-t himarket-admin:$VERSION \
--platform linux/amd64 \
--load .
echo "All images have been built successfully!"