Tool definition: install.yml

December 11, 2022 ยท View on GitHub

PHP Tools: Overview | PHP Tools: options.yml | PHP Tools: install.yml


Contributor Documentation: PHP Tools

Tool definition: install.yml

Top level defines

Yaml keyDescription
checkA check command to test that the tool has been installed correctly.
allIs generic for all PHP versions and will be used whenever no specific version is defined.
7.2A version specific block for PHP 7.2. Its child keys will overwrite what has been defined in all.
Example:
check: yq --version 2>&1 | grep -E '[0-9][.0-9]+' || (yq --version; false)

# Default for all PHP version if no overwrite exists
all:
  type: pip
  version:
  build_dep: []
  run_dep: []
  pre:
  post:


# PHP 5.2 is overwriting the version of yq to install
5.2:
  type: pip
  version: 0.1.0

Second level defines

The following keys can be added below: all, 8.2, 8.1, 8.0, 7.4, ...

Yaml keyRequiredSupports
Shell code
Description
preNoYesSpecify a shell command to be run before module installation.
postNoYesSpecify a shell command to be run after module installation.
build_depNoNoArray Debian packages required to build the module (they won't be present in the final image - only used to built the module) If you don't need any, assign it an empty array: build_dep: [].
run_depNoNoArray Debian packages required for the module run-time (they won't be present during the build stage - only in the final image). If you don't need any, assign it an empty array: run_dep: [].
typeYesNoOn of the following types to build the module: apt, composer, npm, pip, rubygem or custom.

Note: When using type: custom, all data needs to be installed into /usr/local/bin as only this directory is copied into the next docker stage during multi-stage build.

Second level defines for type: apt

Yaml keyRequiredSupports
Shell code
Description
packageYesNoSpecify the Debian apt package to install

Example:

all:
  type: apt
  package: netcat

5.3:
  type: apt
  package: netcat.traditional

Second level defines for type: composer

Yaml keyRequiredSupports
Shell code
Description
packageYesNoSpecify the Composer package name to install
composerYesNoSpecify the composer version to use for installation: 1 or 2
versionNoYesSpecify the Composer package version to install
binaryNoYesSpecify the composer relative binary path to symlink to /usr/loca/bin/
flagsNoYesAdd composer flags to composer require

Example:

all:
  type: composer
  composer: 2
  package: laravel/installer
  binary: bin/laravel

7.1:
  type: composer
  version: 2.3.0
  binary: laravel

Second level defines for type: npm

Yaml keyRequiredSupports
Shell code
Description
packageYesNoSpecify the NPM package name to install
versionNoYesSpecify the NPM package version to install
binaryNoYesSpecify the NPM relative binary path to symlink to /usr/loca/bin/

Example:

all:
  type: npm
  package: pm2
  binary: pm2
  version:

Second level defines for type: pip

Yaml keyRequiredSupports
Shell code
Description
versionNoYesSpecify the Pip package version to install

The PyPI package name defaults to the name specified in options.yml.

Example:

all:
  type: pip
  version:
  build_dep: []
  run_dep: []
  pre:
  post: |
    ln -s pwncat /usr/local/bin/netcat \

Second level defines for type: rubygem

Yaml keyRequiredSupports
Shell code
Description
packageYesNoSpecify the Rubygem package name to install
versionNoYesSpecify the Rubygem package version to install

Example:

all:
  type: rubygem
  package: mdl
  build_dep: [ruby-dev]
  run_dep: [ruby]

7.2:
  type: rubygem
  version: 0.11.0
  pre: |
    gem install chef-utils -v 16.6.14 \

Second level defines for type: custom

Yaml keyRequiredSupports
Shell code
Description
commandYesYesCustom command to install a tool.

Note: When using type: custom, all data needs to be installed into /usr/local/bin as only this directory is copied into the next docker stage during multi-stage build.

Example:

all:
  type: custom
  command: curl -sS -k -L --fail -L "${PHP_CS_FIXER_URL}" -o /usr/local/bin/php-cs-fixer
  pre: PHP_CS_FIXER_URL="https://cs.symfony.com/download/php-cs-fixer-v3.phar"
  post: chmod +x /usr/local/bin/php-cs-fixer

7.3:
  type: custom
  pre: PHP_CS_FIXER_URL="https://cs.symfony.com/download/php-cs-fixer-v2.phar"

Usage of shell code

Single-line vs Multi-line

Note: All keys that support shell code can be written as a single line yaml definition or as a multi line yaml definition. Multi-line yaml definitions need a trailing \ at the end of each line, including the last line.
Single-line:

all:
  pre: VERSION="$( curl http://url | grep -Eo '[0-9.]+' )"

Multi-line:

all:
  pre: |
    VERSION="$( \
      curl http://url \
      | grep -Eo '[0-9.]+' \
    )" \

Single-command vs Multi-command

Note: All keys that support shell code also support to write multiple shell commands. If you use multiple shell commands, you need to separate them with &&.
Single-command:

all:
  pre: |
    VERSION="$( \
      curl http://url \
      | grep -Eo '[0-9.]+' \
    )" \

Multi-command:

all:
  pre: |
    URL="http://url" \
    && VERSION="$( \
      curl "${URL} \
      | grep -Eo '[0-9.]+' \
    )" \
    && echo "${VERSION}" \