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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.