Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Pipelines not working with NPM image and SSH Keys

Tinh Nguyen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 30, 2024

Hello, I'm doing the pipeline deployment for publishing image nodejs container on Docker and inside my nodejs dependency have one private bitbucket repository. I can able to build an run docker install this on my own local docker. But when I try to run on pipelines, it failed on step npm install although I can see it can connect ssh. Here is my docker file

Note: Error is npm fetch 404 for this private package

 

FROM node:18.20.0-alpine3.19 as srcBuild

ARG STAGE

WORKDIR /api

RUN apk update && apk add openssh-client git

COPY id_rsa_model /root/.ssh/id_rsa

RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts

RUN chmod 600 /root/.ssh/id_rsa

RUN eval $(ssh-agent) && ssh-add /root/.ssh/id_rsa

RUN ssh -T git@bitbucket.org

COPY package*.json ./

RUN npm install --verbose

COPY ./ ./

# ENV STAGE_ENV $STAGE

ENTRYPOINT ["sh", "-c" , "npm run start:dev -- $0 $@"]

My dependency

"my-dependency": "git+ssh://git@bitbucket.org/owner/my-dependency.git#v0.0.1"

 

1 answer

2 votes
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 1, 2024

Hi @Tinh Nguyen,

Welcome to the community.

Instead of using the COPY command to pass your existing SSH key in the Docker container, would it be possible for you to use an environment variable instead?
Here's an existing knowledge-based article for the same: Passing SSH key variable from Bitbucket Pipelines to a Dockerfile

Hope it helps.

Regards,
Mark C

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events