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

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

cgoodwin December 9, 2021

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
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 10, 2021

@cgoodwin  hi. Thanks for your question.

Hope this answer and this article can help you.

Regards, Igor.

cgoodwin December 13, 2021

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
AUG Leaders

Atlassian Community Events