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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

pip install a private repo in Bitbucket Pipeline within Dockerfile

I have a private repo that is a dependency as a pip install. I have the proper ssh keys added to the repo I am running the pipeline on, but they are not working within the docker image. How do I get they keys in the docker container so the pip install won't fail?

I have added the following based off of other articles I have read, but once I get to ssh-add ~/.ssh/id_rsa, I get Error loading key "/root/.ssh/id_rsa": invalid format.

 

bitbucket-pipelines.yml

- step:
name: Build and Test
script:
- export SSH_PRIVATE_KEY=`cat /opt/atlassian/pipelines/agent/data/id_rsa`
- IMAGE_NAME=$BITBUCKET_REPO_SLUG
- docker build . --file Dockerfile --tag ${IMAGE_NAME}
- docker save ${IMAGE_NAME} --output "${IMAGE_NAME}.tar"
services:
- docker
caches:
- docker
artifacts:
- "*.tar"

 

Dockerfile

ARG SSH_PRIVATE_KEY

RUN mkdir ~/.ssh/
RUN echo "${SSH_PRIVATE_KEY}" > ~.ssh/id_rsa
RUN chmod 600 ~/.ssh/id_rsa
RUN touch ~/.ssh/known_hosts
RUN ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts
RUN eval $(ssh-agent -s)
RUN ssh-add ~/.ssh/id_rsa

 

1 answer

0 votes

Hi, @Chance Gehrke! Welcome to the community! 

Could you please try to use the following command to build the image?

- docker build --build-arg SSH_PRIVATE_KEY . --file Dockerfile --tag ${IMAGE_NAME}

I hope this helps, but do let me know if you have any questions. 

Kind regards,
Caroline

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

🎨 Add some visual life to your templates

Hi Atlassian Community, My name is Avni Barman, and I am a Product Manager on the Confluence Cloud team. Based on feedback from you, we are giving admins more power to create templates that a...

143 views 1 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you