provision

Specifies a list of commands to be run before the system is ready to run command.

This property exists to give to the system the opportunity to run commands which depend on project files and, due to that, couldn't be run at the image creation moment. Tasks such as installation of dependencies or database migrations are good candidates for this property.

Observations

  • The provision step is run as a single command which is resulted from the concatenation of the command list, separated by &&. Hence, in order to the provision all the commands on that list must return 0 so the provision step be considered as successful. Otherwise, it'll fail and will show the commands output;

  • It's important to notice this isn't where you shuld customize your images, and any information that have to be persisted, should be done using mounted folders.

Usage:

provision: [
    'COMMAND 1',
    'COMMAND 2',
    ...,
    'COMMAND N'
],
Examples:

For systems using Rails it's common to run bundle install and rake db:migrate.

rails_system: {
  provision: [
    "bundle install --path /azk/bundler",
    "bundle exec rake db:migrate",
  ],
  // ...
  mounts: {
    "/azk/#{manifest.dir}": sync("."),
    "/azk/bundler": persistent("bundler"),
  }
},

For systems using Node.js, it's common to use npm install to install the dependencies.

node_system: {
  provision: [
    "npm install"
  ],
  // ...
  mounts: {
    "/azk/#{manifest.dir}": sync("."),
    "/azk/#{manifest.dir}/node_modules": persistent("modules"),
  }
},

It's important to notice that both cases (Rails and Node.js) use persistent folders to store the installed dependencies. Otherwise, those installations would be done on an temporary instance and all data would be lost as soon as the provision step is finished.