Skip to content

Commit b7861d2

Browse files
authored
Update build-image.sh
1 parent 25e1b3c commit b7861d2

File tree

1 file changed

+21
-72
lines changed

1 file changed

+21
-72
lines changed

build-image.sh

Lines changed: 21 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,45 @@
11
#!/bin/bash
22

33
echo "==========================================="
4-
echo "Building KoalaWiki Docker Images"
4+
echo "Building KoalaWiki Docker Images with BuildKit Multi-platform"
55
echo "==========================================="
66

7-
# Enable Docker Buildx
8-
docker buildx create --use
7+
# Enable Docker Buildx with a new builder that supports multi-platform builds
8+
docker buildx create --name multiplatform-builder --use
99

10-
# Build backend image for amd64 platform
11-
echo "Building backend image for amd64 platform..."
10+
# Build and push backend images for multiple platforms at once
11+
echo "Building and pushing backend images for multiple platforms..."
1212
docker buildx build \
13-
--platform linux/amd64 \
14-
-t crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki \
13+
--platform linux/amd64,linux/arm64 \
14+
-t crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:latest \
15+
-t crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:amd64 \
1516
-f src/KoalaWiki/Dockerfile \
16-
--load .
17-
if [ $? -ne 0 ]; then
18-
echo "Error building backend amd64 image!"
19-
exit 1
20-
fi
17+
--push .
2118

22-
# Push backend amd64 image
23-
echo "Pushing backend amd64 image..."
24-
docker push crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki
2519
if [ $? -ne 0 ]; then
26-
echo "Error pushing backend amd64 image!"
20+
echo "Error building and pushing backend images!"
2721
exit 1
2822
fi
2923

30-
# Build backend image specifically for arm64 platform using Dockerfile.arm
31-
echo "Building backend image for arm64 platform using Dockerfile.arm..."
32-
docker buildx build \
33-
--platform linux/arm64 \
34-
-t crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:arm64 \
35-
-f src/KoalaWiki/Dockerfile.arm \
36-
--load .
37-
if [ $? -ne 0 ]; then
38-
echo "Error building backend arm64 image!"
39-
exit 1
40-
fi
41-
42-
# Push backend arm64 image
43-
echo "Pushing backend arm64 image..."
44-
docker push crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:arm64
45-
if [ $? -ne 0 ]; then
46-
echo "Error pushing backend arm64 image!"
47-
exit 1
48-
fi
49-
50-
# Build frontend image for amd64 platform
51-
echo "Building frontend image for amd64 platform..."
24+
# Build and push frontend images for multiple platforms at once
25+
echo "Building and pushing frontend images for multiple platforms..."
5226
pushd web > /dev/null
5327
docker buildx build \
54-
--platform linux/amd64 \
55-
-t crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki-web \
28+
--platform linux/amd64,linux/arm64 \
29+
-t crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki-web:latest \
30+
-t crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki-web:amd64 \
5631
-f Dockerfile \
57-
--load .
58-
if [ $? -ne 0 ]; then
59-
echo "Error building frontend amd64 image!"
60-
exit 1
61-
fi
32+
--push .
6233

63-
# Push frontend amd64 image
64-
echo "Pushing frontend amd64 image..."
65-
docker push crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki-web
6634
if [ $? -ne 0 ]; then
67-
echo "Error pushing frontend amd64 image!"
35+
echo "Error building and pushing frontend images!"
6836
exit 1
6937
fi
7038
popd > /dev/null
7139

72-
# Build frontend image for arm64 platform
73-
echo "Building frontend image for arm64 platform..."
74-
pushd web > /dev/null
75-
docker buildx build \
76-
--platform linux/arm64 \
77-
-t crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki-web:arm64 \
78-
-f Dockerfile.arm \
79-
--load .
80-
if [ $? -ne 0 ]; then
81-
echo "Error building frontend arm64 image!"
82-
exit 1
83-
fi
84-
85-
# Push frontend arm64 image
86-
echo "Pushing frontend arm64 image..."
87-
docker push crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki-web:arm64
88-
if [ $? -ne 0 ]; then
89-
echo "Error pushing frontend arm64 image!"
90-
exit 1
91-
fi
92-
popd > /dev/null
40+
# Clean up the builder
41+
docker buildx rm multiplatform-builder
9342

9443
echo "==========================================="
95-
echo "Images built and pushed successfully!"
96-
echo "==========================================="
44+
echo "All images built and pushed successfully!"
45+
echo "==========================================="

0 commit comments

Comments
 (0)