带有 docker 和 yarn 的 SSH 私有存储库

问题描述

我们目前正在使用 ssh 和 npm 提取私有存储库。

# Syntax=docker/dockerfile:experimental
FROM node:14.15.4-alpine
EXPOSE 4800

# Below is needed so that postinstall scripts can run inside docker
RUN npm set unsafe-perm true

copY . /workspace
workdir /workspace
# Install ssh client and git
RUN apk add --no-cache openssh-client git

# Download public key for github.com
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/kNown_hosts

RUN --mount=type=ssh npm ci

CMD ["npm","run","start:docker"]

一切正常。但是,由于其他原因,我们想转向纱线。但是这个

# Syntax=docker/dockerfile:experimental
FROM node:14.15.4-alpine
EXPOSE 4800

# Below is needed so that postinstall scripts can run inside docker
RUN yarn config set unsafe-perm true

copY . /workspace
workdir /workspace
# Install ssh client and git
RUN apk add --no-cache openssh-client git

# Download public key for github.com
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/kNown_hosts

RUN --mount=type=ssh yarn install

CMD ["yarn","start:docker"]

在私有存储库上抛出 401。我还应该补充一点,使用 yarn 在本地构建没有问题。所以 SSH 密钥是正确的。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)