Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
303 views
in Technique[技术] by (71.8m points)

travis build docker image with git ssh

I am trying to rollout one of my build using travis. As part of the pre script I am building a docker image. Within the docker image, I need to get a package from my git repository. git is trying to do ssh and I am trying to get it to use https. Can anyone see what I might be doing wrong?

Docker file

FROM node:15-alpine as builder
RUN apk update
RUN apk add --no-cache git
RUN git config --global url."https://github.com/".insteadOf [email protected]:
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 output

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

An URL of a dependency starts with ssh:// and you haven't added a rule to rewrite such URLs. Add one:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...