dm/build.sh

53 lines
1.1 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() {
2024-07-01 21:48:29 +08:00
local service_name=$1
2024-06-20 14:55:36 +08:00
read -p "是否要推送到《达梦启元云原生大数据平台》? [Y/N] " confirm
if [[ $confirm =~ ^[yY]([eE][sS])?$ ]]; then
2024-07-01 21:48:29 +08:00
echo "${service_name} tag"
docker tag "${service_name}" 36.138.114.105:31000/cnsof50011836/$service_name
echo "${service_name} pushing"
docker push 36.138.114.105:31000/cnsof50011836/$service_name
echo "${service_name} pushed"
2024-06-20 14:55:36 +08:00
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
2024-07-01 21:48:29 +08:00
push_image flask-app
push_image base-dm
2024-06-20 14:55:36 +08:00
echo "脚本结束"
}
main