Files
unicut/scripts/push_registry.sh

43 lines
1.8 KiB
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
# 发版推送 unicut 镜像到自建 Gitea Registry(gitea.88531.cn)
#
# 为什么用 skopeo 走内网直推:
# 公网链路(VPS nginx → 隧道 → Gitea)带 client_max_body_size 限制,
# docker push 大层会被 413 Request Entity Too Large 拦下;
# 内网 http://192.168.68.19:3200 直推无此限制,推完公网 gitea.88531.cn
# 即可拉取(拉取是 GET 响应,不受请求体积限制影响)。
#
# 用法:bash scripts/push_registry.sh [镜像:tag] [版本tag]
# 默认:unicut-src-unicut:latest → :latest + :v<package.json 版本>
set -euo pipefail
IMG="${1:-unicut-src-unicut:latest}"
DEFAULT_VER="v$(grep -oP '"version":\s*"\K[^"]+' package.json | head -1)"
VERSION_TAG="${2:-${DEFAULT_VER:-v1.0.0}}"
REG="192.168.68.19:3200" # 内网 Gitea(绕开公网 nginx)
OWNER="jinghui"
PKG="unicut"
TOKEN="$(sed 's/^Bearer //' /root/.gitea_token)"
TMP="$(mktemp -d /tmp/push_registry.XXXXXX)"
trap 'rm -rf "$TMP"' EXIT
echo "[1/3] docker save ${IMG} → ${TMP}/img.tar"
docker save "${IMG}" -o "${TMP}/img.tar"
echo "[2/3] 推送 latest → ${REG}/${OWNER}/${PKG}:latest"
skopeo copy \
--dest-tls-verify=false --dest-username="${OWNER}" --dest-password="${TOKEN}" \
"docker-archive:${TMP}/img.tar:${IMG}" \
"docker://${REG}/${OWNER}/${PKG}:latest"
echo "[3/3] 同步版本 tag → :${VERSION_TAG}"
skopeo copy \
--src-tls-verify=false --src-username="${OWNER}" --src-password="${TOKEN}" \
--dest-tls-verify=false --dest-username="${OWNER}" --dest-password="${TOKEN}" \
"docker://${REG}/${OWNER}/${PKG}:latest" \
"docker://${REG}/${OWNER}/${PKG}:${VERSION_TAG}"
echo "完成。公网免登录可拉:"
echo " docker pull gitea.88531.cn/${OWNER}/${PKG}:latest"
echo " docker pull gitea.88531.cn/${OWNER}/${PKG}:${VERSION_TAG}"