Files

19 lines
762 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 本地构建 CAS 镜像并推送到阿里云「公网」 registry
# 用法: ./build-push.sh <version>
# 前置环境变量: ACR_NAMESPACE, ACR_USERNAME, ACR_PASSWORD
set -euo pipefail
VERSION="${1:-latest}"
REGISTRY="${ACR_REGISTRY_PUBLIC:-registry.cn-hangzhou.aliyuncs.com}"
NAMESPACE="${ACR_NAMESPACE:?请设置 ACR_NAMESPACE(阿里云镜像命名空间)}"
IMG="$REGISTRY/$NAMESPACE/yunhai:$VERSION"
cd "$(dirname "$0")/.." # 切到项目根(构建上下文需含 target/cas.war)
echo "== build $IMG =="
docker build -f docker/Dockerfile -t "$IMG" .
echo "== login $REGISTRY =="
echo "$ACR_PASSWORD" | docker login --username="$ACR_USERNAME" --password-stdin "$REGISTRY"
echo "== push =="
docker push "$IMG"
echo "PUSHED $IMG"