Using workspaces to speed up base image setup


#1

I was wondering if workspaces could be used during the “spin up environment” phase to speed up initialization.

We have a few different languages we work in, and use workflows to run each in parallel. They all share the same base image. However, we loose between a minute and 3 every time the image cache is not found on the host for each job.

It is unfortunate that a workflow that uses the same image has to retrieve it again externally (unless you get lucky and the same container host is used, but seems to happen like 5% of the time). Maybe something can be done with workspaces?

An example config like:

version: 2
jobs:
  setup_workspace:
    working_directory: ~/app
    docker:
      - image: cfht/api-build
    steps:
      - checkout

      - persist_to_workspace:
           root: .
          paths:
            - .


  python:
    docker:
      - image: cfht/api-build
    working_directory: ~/app

     steps:
      - attach_workspace:
          at: ~/app

      - restore_cache:
        ...

      - run:
        ...

  web:
    docker:
      - image: cfht/api-build
      - image: selenium/standalone-chrome:3.8.1
    working_directory: ~/app/account/web

    steps:
      - attach_workspace:
        at: ~/app

      - restore_cache:
        ...

      - run:
        ...

workflows:
  version: 2
  build:
    jobs:
      - setup_workspace
      - python:
          requires:
            - setup_workspace
      - web:
          requires:
            - setup_workspace

#2

How big is cfht/api-build, and where is it fetched from? Is it your image or a DockerHub one?

You could make a custom Docker image (in a separate CI build) and then pull it from a private registry. If you can keep this to a small-ish size then you might be able to achieve a speed increase.


#3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.