travis 使用 git ssh 构建 docker 镜像

时间:2021-01-11 13:06:23

标签: git docker npm travis-ci

我正在尝试使用 travis 推出我的构建之一。作为预脚本的一部分,我正在构建一个 docker 镜像。在 docker 镜像中,我需要从我的 git 存储库中获取一个包。 git 正在尝试执行 ssh,而我正在尝试让它使用 https。谁能看到我可能做错了什么?

Docker 文件

FROM node:15-alpine as builder
RUN apk update
RUN apk add --no-cache git
RUN git config --global url."https://github.com/".insteadOf git@github.com:
RUN git config --global url."https://".insteadOf git://
COPY package.json .
RUN npm install

travis.yml

sudo: required

language: node_js
node_js:
  - '14'

services:
  - docker

before_install:
  - if [ "$TRAVIS_BRANCH" == "nightly" ]; then docker build -t something/clientv1 -f ./app/Dockerfile.nightly ./app; fi
  - if [ "$TRAVIS_BRANCH" == "staging" ]; then docker build -t something/clientv1 -f ./app/Dockerfile.staging ./app; fi
  - if [ "$TRAVIS_BRANCH" == "beta" ]; then docker build -t something/clientv1 -f ./app/Dockerfile.beta ./app; fi
  - docker build -t something/nginx ./nginx
  - docker build -t something/api ./server

script:
  - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_ID" --password-stdin
  - if [ "$TRAVIS_BRANCH" = "nightly" ] || [ "$TRAVIS_BRANCH" = "staging"] || [ "$TRAVIS_BRANCH" = "beta" ]; docker push something/clientv1; fi
  - docker push something/nginx
  - docker push something/api

deploy:
...

package.json

...      
"dependencies": {
         "react-awesome-query-builder": "https://github.com/billtlee/react-awesome-query-builder.git#forLocal"
      }
...

travis 输出

npm notice 
npm ERR! code 128
npm ERR! command failed
npm ERR! command git ls-remote ssh://git@github.com/[secure]/react-awesome-query-builder.git
npm ERR! error: cannot run ssh: No such file or directory
npm ERR! fatal: unable to fork

2 个答案:

答案 0 :(得分:0)

依赖项的 URL 以 ssh:// 开头,并且您尚未添加重写此类 URL 的规则。添加一个:

RUN git config --global url."https://".insteadOf ssh://git@

答案 1 :(得分:0)

我通过从 15-alpine 降级到 14-alpine 使其工作。不知道有什么变化但是不管我做什么,它一直想使用 ssh...