ypk-deploy-tool/docker/buildDocker.sh
2022-05-26 15:33:04 +08:00

25 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
if [ $# -gt 2 ]; then
echo "too many arguments,\nusage: \$version [-,push,save] \$saveDir"
exit 1
fi
version=$(awk '/version "[0-9]/ { sub(/[^"]*"/,"") ; sub(/".*$/,""); print $0 } ' build.gradle)
cp ./docker/Dockerfile ./build/Dockerfile
cd ./build
DOCKER_CLI_EXPERIMENTAL=enabled
if [ "$1" == "push" ]; then
echo "push to docker hub"
docker buildx build --platform linux/arm64/v8,linux/amd64 -t bdware/ypk-deploy-tool:$version ./ --push
elif [ "$1" == "save" ]; then
echo "save to $2"
docker buildx build --platform linux/arm64/v8 -t bdware/ypk-deploy-tool:arm_$version ./ --load
docker save -o $2/ypk-deploy-tool-arm_$version.tar bdware/ypk-deploy-tool:arm_$version
docker buildx build --platform linux/amd64 -t bdware/ypk-deploy-tool:amd64_$version ./ --load
docker save -o $2/ypk-deploy-tool-amd64_$version.tar bdware/ypk-deploy-tool:amd64_$version
else
echo "create at local"
docker build -t bdware/ypk-deploy-tool:$version ./
docker tag bdware/ypk-deploy-tool:$version bdware/ypk-deploy-tool:latest
fi