dm/build.sh

55 lines
1.2 KiB
Bash

#!/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() {
local service_name=$1
read -p "是否要推送到《达梦启元云原生大数据平台》? [Y/N] " confirm
if [[ $confirm =~ ^[yY]([eE][sS])?$ ]]; then
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"
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
build_image code-server
push_image flask-app
push_image base-dm
push_image code-server
echo "脚本结束"
}
main