Dockerfile `RUN –mount=type=ssh` does'nt work with ssh repository dependancies inside package.json / package-lock.json

huangapple go评论62阅读模式
英文:

Dockerfile `RUN --mount=type=ssh` does'nt work with ssh repository dependancies inside package.json / package-lock.json

问题

在 Dockerfile 中:

RUN --mount=type=ssh /usr/local/bin/npm install --loglevel silly

使用选项运行:

--ssh default=$HOME/.ssh/id_ed25519

在 package.json 中:

"dependance": "git+ssh://git@gitlab.xxxx.xxx:common/dependance.git#v4.0.0-pre.7"

在 package-lock.json 中:

"version": "git+ssh://git@gitlab.xxxx.xxx:common/dependance.git#4db813c75b98977b10886ceeb761f5f0fcf92f40", "from": "git+ssh://git@gitlab.xxxx.xxx:common/dependance.git#v4.0.0-pre.7",

--mount=type=ssh 无法克隆依赖,因为它无法看到私钥授权。

英文:

I tried to build a nodejs application with ssh external dependancies with and without package-lock.json in a Dockerfile.

It seems that --mount=type=ssh doesn't works recursively when cloning external ssh dependancies with npm

package-lock.json contains :
"version": "git+ssh://git@gitlab.xxxx.xxx:common/dependance.git#4db813c75b98977b10886ceeb761f5f0fcf92f40",
"from": "git+ssh://git@gitlab.xxxx.xxx:common/dependance.git#v4.0.0-pre.7",

It seems that if I remove the package-lock.json it will work but it doesn't work if it is present, I don't know why.

I don't understand why the secret or mount option is not recursively used within the npm "subprocess" retrieve command.

Though Fixing the versions with the package-lock.json should be built-in.

This is a snake that bites its own tail case.

> Docker version 24.0.2, build cb74dfcd85

In the Dockerfile :

RUN --mount=type=ssh /usr/local/bin/npm install --loglevel silly

Run with option :

--ssh default=$HOME/.ssh/id_ed25519

In the package.json :

"dependance": "git+ssh://git@gitlab.xxxx.xxx:common/dependance.git#v4.0.0-pre.7"

In the package-lock.json :

"version": "git+ssh://git@gitlab.xxxx.xxx:common/dependance.git#4db813c75b98977b10886ceeb761f5f0fcf92f40", "from": "git+ssh://git@gitlab.xxxx.xxx:common/dependance.git#v4.0.0-pre.7",

--mount=type=ssh doesn't clone the dependance because it can't see the private key authorization

答案1

得分: 0

错误:

git+ssh://git@gitlab.xxxx.xxx:common/dependance.git#v4.0.0-pre.7

正确:

git+ssh://git@gitlab.xxxx.xxx/common/dependance.git#v4.0.0-pre.7
英文:

I figured out that the url syntax is wrong:

Wrong:

git+ssh://git@gitlab.xxxx.xxx:common/dependance.git#v4.0.0-pre.7

Correct:

git+ssh://git@gitlab.xxxx.xxx/common/dependance.git#v4.0.0-pre.7

huangapple
  • 本文由 发表于 2023年7月17日 18:30:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76703582.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定