dm/build.sh

51 lines
1.0 KiB
Bash
Raw Normal View History

2024-06-20 14:55:36 +08:00
#!/bin/bash
# 获取当前文件夹名字
current_dir=$(basename "$PWD")
# 确保有稳定的网络环境
ensure_network() {
read -p "请确保有稳定的网络环境[Y/N] " confirm
if [[ ! $confirm =~ ^[yY]([eE][sS])?$ ]]; then
exit 1
fi
}
# 打包镜像
build_image() {
local service_name=$1
echo "打包${service_name}镜像"
docker compose build "$service_name"
}
# 推送镜像
push_image() {
read -p "是否要推送到《达梦启元云原生大数据平台》? [Y/N] " confirm
if [[ $confirm =~ ^[yY]([eE][sS])?$ ]]; then
echo "tag"
docker tag "${current_dir}-flask-app" 36.138.114.105:31000/cnsof50011836/flask-app
echo "pushing"
docker push 36.138.114.105:31000/cnsof50011836/flask-app
echo "pushed"
else
echo "用户选择不推送镜像"
fi
}
# 主流程
main() {
echo "打包中"
ensure_network
build_image base
build_image base-dm
build_image build-dmpython
build_image build-frontend
build_image flask-app
push_image
echo "脚本结束"
}
main