The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Pipeline for deploying to docker hub with pip caches

Alexandros Davies
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!
May 31, 2019

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 11, 2019

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

TAGS
AUG Leaders

Atlassian Community Events