谁能解释一下为什么要从node:14-alpine
to node:16-alpine
会导致npm安装失败吗?
> [ 8/10] RUN --mount=type=ssh npm i:
#14 14.27 npm ERR! code 128
#14 14.28 npm ERR! An unknown git error occurred
#14 14.28 npm ERR! command git --no-replace-objects ls-remote ssh://[email protected] /cdn-cgi/l/email-protection/(somerepo).git
#14 14.28 npm ERR! Warning: Permanently added 'github.com' (RSA) to the list of known hosts.
#14 14.28 npm ERR! [email protected] /cdn-cgi/l/email-protection: Permission denied (publickey).
#14 14.28 npm ERR! fatal: Could not read from remote repository.
#14 14.28 npm ERR!
#14 14.28 npm ERR! Please make sure you have the correct access rights
#14 14.28 npm ERR! and the repository exists.
这是一个:
git+ssh://[email protected] /cdn-cgi/l/email-protection:someorg/somerepo
依赖性。构建是使用以下命令运行的:
DOCKER_BUILDKIT=1 docker build --ssh default .
我没有发现任何明显的变化image https://github.com/nodejs/docker-node/tree/main,这让我怀疑 npm (从 6.14.15 到 8.1.0),但我找不到任何记录(并且它在容器外工作正常)
编辑:Dockerfile 如下所示:
# syntax=docker/dockerfile:experimental
FROM node:16-alpine
RUN apk --no-cache --virtual build-dependencies add \
python2 \
make \
g++ \
git \
openssh
# Download public key for github.com
RUN mkdir -p /root/.ssh && \
chmod 0700 /root/.ssh && \
ssh-keyscan github.com >> /root/.ssh/known_hosts
WORKDIR /app/
RUN chown -R node $PWD
RUN apk add postgresql-client
ADD ./service/package.json .
RUN --mount=type=ssh npm i
RUN apk del build-dependencies && rm -r /root/.ssh
ADD ./service/ .
CMD node ./app.js
USER node
我所做的唯一改变是FROM
编辑2:如果我在节点14映像中更新npm(到8.1.3),我会遇到同样的问题。但运行ssh -Tv [email protected] /cdn-cgi/l/email-protection
即使在工作版本中也会失败,所以我不知道到目前为止使用了什么黑魔法构建套件
这似乎是 npm8 和 git+ssh 的问题
use yarn
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)