Reusable environments

Attention

This feature is under development, changes are expected

Introduction

Reusable environments is a very useful feature that allows to save a environment at a arbitraty step and reuse later in other environment.

This feature has been desinged and implemented with the goal of save resources.

Tip

For example, in the case of a NodeJS project, you can save a environment after run npm ci and later add npm i. This will be faster as the dependencies are already installed.

Tip

For example, in the case of a Composer based project, you can save a environment after run composer install so next time it runs on a new environment it will just install the missing dependencies.

Tip

In any other case, if your environment have some OS level dependencies, like packages, libraries or whatever, you can install them once in the reusable environment.

Also, new environment will save space as they reuse a common image of dependencies.

Configuration

Configuration about when to create a reusable environment and later where to reuse this is specified in the Qaack file.

There are two directives in the qaack file:

  • make_reusable for specify when to save

  • reuse to specify which reusable environment choose

Caution

If there are differences in the configuration between saved environment and the reusing one, it could result in a unexpected beahviour. Qaack will reuse if all the services matches and the step specified to save exists.

It wont check if new commands have been included, deleted or reorganized has changed.

Lets see each one:

make_reusable

The complete syntax of this directive is:

make_reusable:
  [reusable_label]:
    on: [service].[step]
    where:
      - [git_reference_name]

So the options are:

reusable_label: you can create multiple reusable environments from the same environment. Each one will be identified by a label, which is specified here.

on: This option specifies in which point of the build process will the environment be saved. Its given in the format of [service_name].[step_name]. It will save AFTER the execution of the given step, and the environment reusing will NOT execute it

where: This is a list of git references to restrict when the environments will be saved. This is useful to avoid that all branches saves a environment. If the ref of the environment is not here, this reusable environment will be ignored.

reuse

The syntax is just:

reuse: [label_of_reusable_environment]

Details

Saving the environment

In the build process, after every step on every service is checked if there is any reusable environment configuration directive that matches the current position of the build process.

In the case that any config matches, then all the services are paused, then all saved and then unpaused.

Reusing a environment

The reuse label will be checked before start the create process. The reusable environment will be used a the image to pull instead of the specified by the service config.

Later, when building, Qaack will skip all the steps and services until reach the step specified for the reusable environment.

Reusing environment files will be placed over the saved ones, without any file merge mechanisim.

Example

make_reusable:
  reusable1:
    on: Y.b
    where:
      - develop

  full_site:
    on: Z.f
    where:
      - develop

reuse: full_site