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

Pipeline for deploying to docker hub with pip caches

Hi There,

I'm using Pipelines to build Docker images and deploy them to Docker Hub. The Docker images contain python scripts, with dependencies held in requirements.txt - I imagine a standard configuration for users.

My pipelines file looks like this:

# bitbucket-pipelines.yml

image
: atlassian/default-image:2
pipelines:
default:
- step:
services:
- docker script: # Modify the commands below to build your repository. # Set $DOCKER_HUB_USERNAME and $DOCKER_HUB_PASSWORD as environment variables in repository settings
- export IMAGE_NAME=blah/blah:latest
- docker build -t $IMAGE_NAME .
- docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
- docker push $IMAGE_NAME


 And my Dockerfile looks like this:

# Dockerfile

FROM
python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . /usr/src/app
CMD ["python", "main.py"]

I'd like to cache the requirements used by pip but I'm facing permissions errors when trying to access ~/.caches/pip. Has anyone had this working that can share the modifications they made?

 

Thanks!

1 answer

0 votes

Hello,

Are you trying to use the default Pip cache provided by Pipelines? You need to add that to your bitbucket-pipelines.yml:

# bitbucket-pipelines.yml

image
: atlassian/default-image:2
pipelines:
default:
- step:
caches: # Add this!
- pip
services:
- docker script: # Modify the commands below to build your repository. # Set $DOCKER_HUB_USERNAME and $DOCKER_HUB_PASSWORD as environment variables in repository settings
- export IMAGE_NAME=blah/blah:latest
- docker build -t $IMAGE_NAME .
- docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
- docker push $IMAGE_NAME

What was the exact error message you were getting? Did it provide more details?

Thanks,

Phil

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

3,761 views 64 20
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