Container Setup Separation



Many of my OSS projects use complex setup: i need to customize environment (e.g. install PHP libraries) and install additional tools (i.e. Allure Framework, which, in turn, requires JVM, so i’m installing Jabba, Zulu@1.9.0 and Allure Framework). This happens on every build and bumps build time, pushing get-feedback-asap paradigm away. i think it is possible to allow users to define container setup - relatively static set of commands that define container content, result of which is committed as a new image and cached, skipping those steps on next build:

  - image: 'circleci/php:7.1'
      - curl -sL | bash && . ~/.jabba/
      - jabba install zulu@1.9.0
      - sudo docker-php-ext-install bcmath
      - echo 'memory_limit = -1' | sudo tee -a /usr/local/etc/php/php.ini
      - echo 'date.timezone = UTC' | sudo tee -a /usr/local/etc/php/php.ini

Those commands can easily eat away more than a minute of build time, which i would love to keep short. This, of course, would also require additional space for cached images, but they may be limited in numbers (e.g. only one such image per project - if setup section has changed between builds, discard old one and create new), also currently i’m doing quite the same using regular cache commands.


A minute is not a great deal of time, though I see what you mean. If you want a really fast built time, there is probably a point where you need to abandon hosted CI and store an always-available build on a VPS. You can then just git pull and run a build command when your build trigger is activated. Given that your software will be installed already and the repo already mostly downloaded, there will be minimal set-up time.

FWIW I build everything in Docker and push/pull the images from a third party registry, but there is probably still a minute of pulling all the images and unpacking them, even on the fast network Circle will be on.