Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,368,293
Community Members
 
Community Events
168
Community Groups

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

Atlassian Community Events