-
Notifications
You must be signed in to change notification settings - Fork 26
/
plugin.sh
executable file
·45 lines (34 loc) · 1.26 KB
/
plugin.sh
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
#!/usr/bin/env bash
set -ex
[ -d ./rootfs ] && rm -rf ./rootfs
mkdir ./rootfs
echo "Creating root filesystem for plugin ..."
docker image build --load -t rootfsimage .
id=`docker container create rootfsimage true`
docker container export "$id" | tar -x -C ./rootfs
echo "Creating plugin "${REPO}:${VERSION}" ..."
docker plugin create "${REPO}:${VERSION}" .
echo "Cleanup..."
docker container rm -f "$id" > /dev/null
docker image rm -f rootfsimage > /dev/null
rm -rf ./rootfs
platforms=("linux/amd64" "linux/arm64")
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
[ -d ./rootfs ] && rm -rf ./rootfs
mkdir ./rootfs
echo "Creating root filesystem for plugin ..."
docker buildx build --load --platform ${platform} -t rootfsimage-${GOOS}-${GOARCH} .
#docker image build -t rootfsimage .
id=`docker container create --platform ${platform} rootfsimage-${GOOS}-${GOARCH} true`
docker container export "$id" | tar -x -C ./rootfs
echo "Creating plugin "${REPO}:${VERSION}-${GOOS}-${GOARCH}" ..."
docker plugin create "${REPO}:${VERSION}-${GOOS}-${GOARCH}" .
echo "Cleanup..."
docker container rm -f "$id" > /dev/null
docker image rm -f rootfsimage-${GOOS}-${GOARCH} > /dev/null
rm -rf ./rootfs
done