|
| 1 | +# Extension definition: `build.yml` |
| 2 | + |
| 3 | + |
| 4 | +## Top level defines |
| 5 | + |
| 6 | +| Yaml key | Description | |
| 7 | +|-----------------|-------------| |
| 8 | +| `already_avail` | Array of PHP versions for which we don't have to install the module as it is already present via its FROM image. | |
| 9 | +| `all` | Is generic for all PHP versions and will be used whenever no specific version is defined. | |
| 10 | +| `7.2` | A version specific block for PHP 7.2. Its child keys will overwrite what has been defined in `all`. | |
| 11 | + |
| 12 | +**Example:** Using `already_avail` |
| 13 | +```yaml |
| 14 | +# "{{ php_all_versions }}" Jinja2 variable is available and |
| 15 | +# translates to an array of all available PHP versions. |
| 16 | +already_avail: "{{ php_all_versions }}" |
| 17 | +``` |
| 18 | +
|
| 19 | +**Example:** Overwriting `git_ref` for a specific version |
| 20 | +```yaml |
| 21 | +already_avail: [5.2] |
| 22 | +all: |
| 23 | + type: git |
| 24 | + git_url: https://github.com/phalcon/cphalcon |
| 25 | + git_ref: master |
| 26 | +# PHP 8.1 is using a different git_ref |
| 27 | +8.1: |
| 28 | + git_ref: v1.0.0 |
| 29 | +# PHP 8.0 is using a different git_ref dynamically with latest tag found |
| 30 | +# See the usage of supported shell code |
| 31 | +8.0: |
| 32 | + git_ref: $( git tag | sort -V | tail -1 ) |
| 33 | +``` |
| 34 | + |
| 35 | + |
| 36 | +## Second level defines |
| 37 | + |
| 38 | +The following keys can be added below: `all`, `8.2`, `8.1`, `8.0`, `7.4`, ... |
| 39 | + |
| 40 | +| Yaml key | Required | Supports<br/>Shell code | Description | |
| 41 | +|-------------|----------|-------------------------|-------------| |
| 42 | +| `pre` | No | Yes | Specify a shell command to be run before module installation. | |
| 43 | +| `post` | No | Yes | Specify a shell command to be run after module installation. | |
| 44 | +| `build_dep` | No | No | Array 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: []`. | |
| 45 | +| `run_dep` | No | No | Array 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: []`. | |
| 46 | +| `type` | **Yes** | No | On of the following types to build the module: `builtin`, `pecl`, `git`, `custom`. | |
| 47 | + |
| 48 | +**Example:** |
| 49 | +```yaml |
| 50 | +all: |
| 51 | + type: builtin |
| 52 | + pre: | |
| 53 | + ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE))" \ |
| 54 | + post: | |
| 55 | + rm -f /tmp/file.txt \ |
| 56 | + build_dep: [libmcrypt-dev] |
| 57 | + run_dep: [libmcrypt4] |
| 58 | +8.1: |
| 59 | + type: builtin |
| 60 | + build_dep: [] |
| 61 | + run_dep: [] |
| 62 | +``` |
| 63 | + |
| 64 | + |
| 65 | +## Second level defines for `type: builtin` |
| 66 | + |
| 67 | +| Yaml key | Required | Supports<br/>Shell code | Description | |
| 68 | +|-------------|----------|-------------------------|-------------| |
| 69 | +| `configure` | No | Yes | Add `./configure` arguments. E.g.:<br/> `configure: --with-jpeg --with-png` | |
| 70 | + |
| 71 | +**Example:** |
| 72 | +```yaml |
| 73 | +all: |
| 74 | + type: builtin |
| 75 | +8.1: |
| 76 | + type: builtin |
| 77 | + configure: --with-jpeg --with-png |
| 78 | +8.0: |
| 79 | + type: builtin |
| 80 | + configure: --with-jpeg |
| 81 | +``` |
| 82 | + |
| 83 | + |
| 84 | +## Second level defines for `type: pecl` |
| 85 | + |
| 86 | +| Yaml key | Required | Supports<br/>Shell code | Description | |
| 87 | +|-------------|----------|-------------------------|-------------| |
| 88 | +| `version` | No | Yes | Pecl packet version | |
| 89 | +| `command` | No | Yes | Overwrite pecl command (default: `pecl install <ext>`) | |
| 90 | + |
| 91 | +**Example:** |
| 92 | +```yaml |
| 93 | +all: |
| 94 | + type: pecl |
| 95 | + command: echo "/usr" | pecl install amqp |
| 96 | + build_dep: [librabbitmq-dev] |
| 97 | + run_dep: [librabbitmq4] |
| 98 | +5.5: |
| 99 | + type: pecl |
| 100 | + version: 1.9.3 |
| 101 | + run_dep: [librabbitmq1] |
| 102 | +``` |
| 103 | + |
| 104 | + |
| 105 | +## Second level defines for `type: git` |
| 106 | + |
| 107 | +| Yaml key | Required | Supports<br/>Shell code | Description | |
| 108 | +|-------------|----------|-------------------------|-------------| |
| 109 | +| `git_url` | **Yes** | Yes | Git repository URL | |
| 110 | +| `git_ref` | No | Yes | Tag, branch, commit to check out (shell code supported to dynamically checkout) | |
| 111 | +| `configure` | No | Yes | Add `./configure` arguments. | |
| 112 | +| `command` | No | Yes | Overwrite default command (default: `phpize && ./configure && make && make install`) | |
| 113 | + |
| 114 | +**Example:** |
| 115 | +```yaml |
| 116 | +already_avail: [5.2] |
| 117 | +all: |
| 118 | + type: git |
| 119 | + git_url: https://github.com/phalcon/cphalcon |
| 120 | + git_ref: master |
| 121 | +# PHP 8.1 is using a different git_ref |
| 122 | +8.1: |
| 123 | + git_ref: v1.0.0 |
| 124 | +# PHP 8.0 is using a different git_ref dynamically with latest tag found |
| 125 | +# See the usage of supported shell code |
| 126 | +8.0: |
| 127 | + git_ref: $( git tag | sort -V | tail -1 ) |
| 128 | +``` |
| 129 | + |
| 130 | + |
| 131 | +## Second level defines for `type: custom` |
| 132 | + |
| 133 | +| Yaml key | Required | Supports<br/>Shell code | Description | |
| 134 | +|-------------|----------|-------------------------|-------------| |
| 135 | +| `command` | **Yes** | Yes | Custom command to install and enable a module | |
| 136 | + |
| 137 | +**Example:** |
| 138 | +```yaml |
| 139 | +all: |
| 140 | + type: custom |
| 141 | + command: | |
| 142 | + wget http://url/file.tar.gz \ |
| 143 | + && tar xvfz file.tar.gz \ |
| 144 | + && cd file \ |
| 145 | + && phpize \ |
| 146 | + && ./configure \ |
| 147 | + && make \ |
| 148 | + && make install \ |
| 149 | +``` |
| 150 | + |
| 151 | + |
| 152 | +## Usage of shell code |
| 153 | + |
| 154 | +### Single-line vs Multi-line |
| 155 | + |
| 156 | +**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.<br/> |
| 157 | +**Single-line:** |
| 158 | +```bash |
| 159 | +all: |
| 160 | + pre: VERSION="$( curl http://url | grep -Eo '[0-9.]+' )" |
| 161 | +``` |
| 162 | +**Multi-line:** |
| 163 | +```bash |
| 164 | +all: |
| 165 | + pre: | |
| 166 | + VERSION="$( \ |
| 167 | + curl http://url \ |
| 168 | + | grep -Eo '[0-9.]+' \ |
| 169 | + )" \ |
| 170 | +``` |
| 171 | + |
| 172 | +### Single-command vs Multi-command |
| 173 | + |
| 174 | +**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 `&&`.<br/> |
| 175 | +**Single-command:** |
| 176 | +```bash |
| 177 | +all: |
| 178 | + pre: | |
| 179 | + VERSION="$( \ |
| 180 | + curl http://url \ |
| 181 | + | grep -Eo '[0-9.]+' \ |
| 182 | + )" \ |
| 183 | +``` |
| 184 | +**Multi-command:** |
| 185 | +```bash |
| 186 | +all: |
| 187 | + pre: | |
| 188 | + URL="http://url" \ |
| 189 | + && VERSION="$( \ |
| 190 | + curl "${URL} \ |
| 191 | + | grep -Eo '[0-9.]+' \ |
| 192 | + )" \ |
| 193 | + && echo "${VERSION}" \ |
| 194 | +
|
| 195 | +``` |
0 commit comments