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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,225 views 0 3
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