You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac M1机器使用Docker部署Spree Commerce时执行bin/setup脚本遇Node安装错误求助

解决Mac M1 Docker部署Spree Commerce时Node环境配置的段错误与GPG问题

我刚帮你分析了终端输出的错误,核心问题是架构不兼容、废弃的apt-key命令和过旧的Node.js版本导致的,下面是具体的修复方案:

错误原因拆解

  1. 架构不匹配:你用的是Mac M1(arm64架构),但Dockerfile里安装Chrome时硬指定了[arch=amd64],下载的Chromedriver也是x86_64版本的chromedriver_linux64.zip,这在arm64环境下会直接引发段错误。
  2. apt-key废弃警告:Debian现在已经不推荐用apt-key add管理密钥,原命令里的curl ... | apt-key add -会导致密钥解析失败,出现gpg: no valid OpenPGP data found.错误。
  3. Node.js 12过旧:Node 12已经停止维护,在arm64的Debian环境下存在兼容性问题,也是段错误的诱因之一。

具体修复步骤

1. 适配arm64架构的Chrome与Chromedriver安装

把Dockerfile中原来的Chrome安装代码替换成以下内容,它会自动检测当前架构并安装对应版本:

# 替换原Chrome安装段落
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor | tee /usr/share/keyrings/google-chrome-keyring.gpg >/dev/null
RUN echo "deb [arch=$(dpkg --print-architecture)] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
RUN apt-get update && apt-get install -y google-chrome-stable

# 下载对应架构的Chromedriver(自动匹配Chrome版本)
RUN CHROMEDRIVER_VERSION=$(google-chrome --version | grep -oP 'Chrome \K\d+') \
    && wget -q --continue -P $CHROMEDRIVER_DIR "https://storage.googleapis.com/chrome-for-testing-public/$CHROMEDRIVER_VERSION.0/linux/$(dpkg --print-architecture)/chromedriver-linux-$(dpkg --print-architecture).zip" \
    && unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR

2. 修复Yarn密钥的正确添加方式

替换原Yarn安装命令为现在官方推荐的keyring方式,避免apt-key的警告和解析错误:

# 替换原Yarn安装段落
RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarnkey.gpg >/dev/null
RUN echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y yarn

3. 升级Node.js到支持arm64的LTS版本

把Node.js从12.x升级到18.x(LTS版本,Spree Commerce完全兼容),解决旧版本的arm64兼容性问题:

# 替换原Node.js安装段落
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y --no-install-recommends nodejs

4. 补充安装apt-utils消除debconf警告

在Dockerfile开头的apt安装命令里加上apt-utils,解决debconf: delaying package configuration的警告:

RUN apt-get update -yq && apt-get upgrade -yq && apt-get install -y -qq --no-install-recommends build-essential curl git-core vim passwd unzip cron gcc wget netcat apt-utils

最后操作

修改完Dockerfile后,重新构建Docker镜像,再运行bin/setup脚本,应该就能顺利完成部署了。

内容的提问来源于stack exchange,提问作者madi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 06:22:27