How to cache/reuse docker image instead of downloading for each step in bitbucket pipeline?

Viewed 205

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

This works fine, but download the image for each step really, really slows it all down.

Is there a way around this?

0 Answers
Related