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

Cache/reuse docker image? Instead of downloading for each step in bitbucket pipeline?

I'm trying to streamline my pipeline a little bit to speed things up (using parallel steps).

The issue that I'm running into is that it downloads the base image for each step; is there a way to avoid that?

I'd like it to use the image I state, but then use a cached version of that for each step afterward. Is that possible??

I've tried a few things but haven't been able to manage it. My pipelines file looks like this:

 

######
# Docker Image
######
image: my_user/test_ci:latest


######
# Step Definitions
######
definitions:
    - step: &build-dev
        name: Build Project With Dev Branches
        caches:
          - pip
        script:
          - git clone --branch dev git@bitbucket.org:my_user/launcher.git
          - git clone --branch dev git@bitbucket.org:my_user/reports.git
        artifacts:
          - reports/**
          - launcher/**
    - step: &install-requirements
        name: Install Requirements
        caches:
          - pip
        script:
          - virtualenv venv
          - source venv/bin/activate
          - pip install -r requirements-dev.txt
        artifacts:
          - reports/**
          - launcher/**
          - venv/**

######
# Pipelines
######
pipelines:
  pull-requests:
    dev:
      - step: *build-dev
      - step: *install-requirements
      - parallel:
          - step:
              name: Test Launcher
              caches:
                - pip
              script:
                - source venv/bin/activate
                - pytest launcher
          - step:
              name: Test Reports
              caches:
                - pip
              script:
                - source venv/bin/activate
                - pytest reports

 

In the past we just put everything together in one big step that ran the tests in the same step. 

I'm trying to break them up to run each independently at the same time (parallel); but downloading our image for every single step is very time consuming. 

1 answer

0 votes

@cgoodwin  hi. Thanks for your question.

Hope this answer and this article can help you.

Regards, Igor.

I wasn't able to implement either of those in a way that did what I was looking for unfortunately. 

We've since reverted our pipeline to just do everything in one step. 

I'll keep looking and hopefully eventually we'll find something.

Suggest an answer

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

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,440 views 4 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