forked from mxx1111/mdlook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-multiarch.sh
More file actions
87 lines (73 loc) · 2.48 KB
/
Copy pathbuild-multiarch.sh
File metadata and controls
87 lines (73 loc) · 2.48 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
#!/bin/bash
set -euo pipefail
RELEASE_DIR="./docker"
REPO_NAME="doocs/md"
PLATFORMS="linux/amd64,linux/arm64"
echo "🔧 Multi-arch Docker build started..."
echo "📁 Scanning directory: $RELEASE_DIR"
for app_ver in "$RELEASE_DIR"/*; do
[ -d "$app_ver" ] || continue
tag=$(basename "$app_ver")
env_file="$app_ver/.env"
if [ ! -f "$env_file" ]; then
echo "⚠️ Skipping $tag - missing .env file"
continue
fi
set -a
. "$env_file"
set +a
echo "🚀 Building images for version: $tag"
echo " VER_APP: $VER_APP"
echo " VER_NGX: $VER_NGX"
echo " VER_GOLANG: $VER_GOLANG"
echo " VER_ALPINE: $VER_ALPINE"
# 构建 base 镜像
if [ -f "$app_ver/Dockerfile.base" ]; then
echo "📦 Building base image: $REPO_NAME:${VER_APP}-assets"
docker buildx build \
--platform "$PLATFORMS" \
--build-arg VER_APP="$VER_APP" \
-f "$app_ver/Dockerfile.base" \
-t "$REPO_NAME:${VER_APP}-assets" \
--push \
"$app_ver"
fi
# 构建 nginx 镜像
if [ -f "$app_ver/Dockerfile.nginx" ]; then
echo "📦 Building nginx image: $REPO_NAME:${VER_APP}-nginx"
docker buildx build \
--platform "$PLATFORMS" \
--build-arg VER_APP="$VER_APP" \
--build-arg VER_NGX="$VER_NGX" \
-f "$app_ver/Dockerfile.nginx" \
-t "$REPO_NAME:${VER_APP}-nginx" \
--push \
"$app_ver"
fi
# 构建 standalone 镜像
if [ -f "$app_ver/Dockerfile.standalone" ]; then
echo "📦 Building standalone image: $REPO_NAME:${VER_APP}"
docker buildx build \
--platform "$PLATFORMS" \
--build-arg VER_APP="$VER_APP" \
--build-arg VER_NGX="$VER_NGX" \
-f "$app_ver/Dockerfile.standalone" \
-t "$REPO_NAME:${VER_APP}" \
--push \
"$app_ver"
fi
# 构建 static 镜像
if [ -f "$app_ver/Dockerfile.static" ]; then
echo "📦 Building static image: $REPO_NAME:${VER_APP}-static"
docker buildx build \
--platform "$PLATFORMS" \
--build-arg VER_APP="$VER_APP" \
--build-arg VER_NGX="$VER_NGX" \
-f "$app_ver/Dockerfile.static" \
-t "$REPO_NAME:${VER_APP}-static" \
--push \
"$app_ver"
fi
echo "✅ Completed version: $tag"
done
echo "🎉 All images built and pushed successfully."