diff --git a/docker-dev/Dockerfile b/docker-dev/Dockerfile index daed027..e94ae4b 100644 --- a/docker-dev/Dockerfile +++ b/docker-dev/Dockerfile @@ -1,10 +1,8 @@ FROM registry.cn-hangzhou.aliyuncs.com/shopex_company/ecshopex-php:ecx-8.2.29-fpm-alpine3.22 -# Node 16:Alpine 3.22 的 apk 不再提供 nodejs 16。 -# 使用 Node 官方 glibc 预编译包 + libc6-compat(gcompat),避免依赖 apk 版本线。 -# 默认从 nodejs.org 下载;中国大陆可加: --build-arg NODE_DIST_BASE=https://npmmirror.com/mirrors/node ARG NODE_VERSION=16.20.2 ARG NODE_DIST_BASE=https://nodejs.org/dist +ARG NODE_MUSL_DIST_BASE=https://unofficial-builds.nodejs.org/download/release # 安装 MySQL、Redis、Nginx、Supervisor 和 Node.js # 基础镜像已包含 PHP 8.2 和 FPM,只需安装其他服务 @@ -35,7 +33,13 @@ RUN apk add --no-cache \ aarch64) NODE_ARCH=arm64 ;; \ *) echo "unsupported architecture: $ARCH (need x86_64 or aarch64)" >&2; exit 1 ;; \ esac \ - && curl -fsSL "${NODE_DIST_BASE}/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${NODE_ARCH}.tar.xz" \ + && if [ "$NODE_ARCH" = "x64" ]; then \ + NODE_TARBALL_URL="${NODE_MUSL_DIST_BASE}/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64-musl.tar.xz"; \ + else \ + NODE_TARBALL_URL="${NODE_DIST_BASE}/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${NODE_ARCH}.tar.xz"; \ + fi \ + && echo "Installing Node from ${NODE_TARBALL_URL}" \ + && curl -fsSL "${NODE_TARBALL_URL}" \ | tar -xJ -C /usr/local --strip-components=1 \ && rm -rf /var/cache/apk/* \ && npm config set registry https://registry.npmmirror.com \ diff --git a/install.sh b/install.sh index 35af871..91a8c09 100644 --- a/install.sh +++ b/install.sh @@ -335,16 +335,32 @@ ensure_docker_compose() { install_docker_compose } +# macOS:/usr/bin/git 有时是 Xcode 占位,会弹窗或要求装 CLT;真正可用的 git 可直接跳过 brew install +macos_git_usable() { + command -v git &>/dev/null || return 1 + local ver + ver="$(git --version 2>&1)" || return 1 + case "$ver" in + *xcode-select*|*xcrun:*error*|*"command line tools"*|*"开发者工具"*) return 1 ;; + esac + [[ "$ver" == git\ version* ]] || return 1 + return 0 +} + ensure_git() { - # macOS 上系统自带的 git 可能是占位符,会触发 Xcode 安装;只有通过 Homebrew 安装的 git 才可靠用于 git clone if [[ "$OS" == "macos" ]]; then + if macos_git_usable; then + ui_success "已检测到 Git: $(git --version 2>&1 | head -n1)" + return 0 + fi if command -v brew &>/dev/null; then - if brew list git &>/dev/null; then + eval "$(brew shellenv)" 2>/dev/null || true + if brew list git &>/dev/null 2>&1; then ui_success "已检测到 Git(Homebrew)" return 0 fi fi - # 无 brew 或 brew 下未安装 git:先确保 Homebrew 再安装 git + # 无可用 git 或 brew 下未安装 git:通过 Homebrew 安装(避免依赖 Xcode) install_git return 0 fi