Skip to content

Commit 52aa0d4

Browse files
committed
Add PHP module dirs
1 parent 40c6d48 commit 52aa0d4

File tree

310 files changed

+5087
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

310 files changed

+5087
-0
lines changed

php_modules/Makefile

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
ifneq (,)
2+
.error This Makefile requires GNU Make.
3+
endif
4+
5+
default: help
6+
7+
# Ensure additional Makefiles are present
8+
MAKEFILES = Makefile.python
9+
$(MAKEFILES): URL=https://raw.githubusercontent.com/devilbox/makefiles/master/$(@)
10+
$(MAKEFILES):
11+
@if ! (curl --fail -sS -o $(@) $(URL) || wget -O $(@) $(URL)); then \
12+
echo "Error, curl or wget required."; \
13+
echo "Exiting."; \
14+
false; \
15+
fi
16+
include $(MAKEFILES)
17+
18+
19+
# -------------------------------------------------------------------------------------------------
20+
# Default configuration
21+
# -------------------------------------------------------------------------------------------------
22+
MYPY_ARGS = --strict --disable-error-code no-any-return
23+
24+
PYLINT_DIR = *.py
25+
PYLINT_PIP_PKGS = yamllint
26+
PYLINT_ARGS = --disable=invalid-name
27+
28+
PYCODE_ARGS = --max-line-length=100
29+
30+
BLACK_LINT_ARGS = -l 100 --check --diff
31+
BLACK_FIX_ARGS = -l 100
32+
33+
34+
# -------------------------------------------------------------------------------------------------
35+
# Default Target
36+
# -------------------------------------------------------------------------------------------------
37+
help:
38+
@echo "make lint # Lint Python sources"

php_modules/README-build.yml.md

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
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+
```

php_modules/README-options.yml.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Extension definition: `options.yml`
2+
3+
To be done
4+
5+
6+
For now have a look at the existing modules into the respective `options.yml` files as they are mostly the same.

php_modules/README-test.yml.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Extension definition: `test.yml`
2+
3+
This is not yet implemented and thus no documentation exists.

php_modules/README.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# PHP Module definitions
2+
3+
This documentation describes how to create new or alter existing PHP module definitions.
4+
5+
All PHP modules/extensions (for all PHP versions and both for `amd64` and `arm64` platforms) are defined in here in their dedicated directory. These definitions are then transformed to Ansible group_vars and afterwards Ansible will generate the corresponding Dockerfiles (Stage: `mods`).
6+
7+
8+
## How to add PHP modules?
9+
10+
1. **Inside `php_modules/` directory:**
11+
1. Create a new directory with the name of the PHP module in `php_modules/`
12+
2. Add `build.yml`, `options.yml` and `test.yml` into your newly created directory
13+
3. Alter `build.yml`, `options.yml` and `test.yml` according to documentation below
14+
4. Run `python3 modules-validate.py` to validate the created PHP module definitions
15+
5. Run `python3 modules-generate.py` to create Ansible group_vars
16+
17+
2. **Inside the root of this git repository:**
18+
1. Run `make gen-dockerfiles` to generate Dockerfiles via Ansible
19+
2. Run `make build STAGE=mods VERSION=8.1 ARCH=linux/amd64` to build the `mods` Docker image with version `8.1` for platform `linux/amd64`
20+
21+
**Note:** If you want to test if your new module builds correctly, you can generate Dockerfiles which only contain your module and all others removed. This allows for much faster Docker builds and you don't have to wait for all other modules to be built. To do so you generate group_vars for your module only via:
22+
23+
```bash
24+
# Only generate group_vars for curl
25+
# Note: if curl has other modules as requiredments to be built beforehand, those will also be added
26+
python3 module-generate.py curl
27+
```
28+
29+
30+
## Extension definition: `build.yml`
31+
32+
See **[README-build.yml.md](README-build.yml.md)** how to alter the `build.yml` file.
33+
34+
35+
## Extension definition: `options.yml`
36+
37+
See **[README-options.yml.md](README-options.yml.md)** how to alter the `options.yml` file.
38+
39+
40+
## Extension definition: `test.yml`
41+
42+
See **[README-test.yml.md](README-test.yml.md)** how to alter the `test.yml` file.

php_modules/amqp/build.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
3+
# Available Jinja2 variables:
4+
# ---------------------------
5+
# * {{ php_all_versions }}: Array of all PHP versions
6+
7+
8+
all:
9+
type: pecl
10+
command: echo "/usr" | pecl install amqp
11+
build_dep: [librabbitmq-dev]
12+
run_dep: [librabbitmq4]
13+
14+
5.5:
15+
type: pecl
16+
version: 1.9.3
17+
run_dep: [librabbitmq1]
18+
19+
5.4:
20+
type: pecl
21+
version: 1.9.3
22+
run_dep: [librabbitmq1]
23+
24+
5.3:
25+
type: pecl
26+
version: 1.9.3
27+
run_dep: [librabbitmq1]
28+
29+
5.2:
30+
type: pecl
31+
version: 1.6.1
32+
run_dep: [librabbitmq1]

php_modules/amqp/options.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
3+
# The name of the module
4+
name: amqp
5+
6+
# Exclude module build/installation for the following PHP versions
7+
exclude: []
8+
9+
# In order for this module to built correctly against all dependencies,
10+
# the following modules must have been built first.
11+
depends_build: []
12+
13+
# In order for this module to function correctly,
14+
# the following modules must be loaded before.
15+
depends_load: []
16+
17+
# Enable this module by default via php.ini for PHP cli command?
18+
enabled_php_cli: true
19+
20+
# Enable this module by default via php.ini for PHP-FPM?
21+
enabled_php_fpm: true

php_modules/amqp/test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+

php_modules/apcu/build.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
3+
# Available Jinja2 variables:
4+
# ---------------------------
5+
# * {{ php_all_versions }}: Array of all PHP versions
6+
7+
8+
all:
9+
type: pecl
10+
11+
5.6:
12+
type: pecl
13+
version: 4.0.11
14+
15+
5.5:
16+
type: pecl
17+
version: 4.0.11
18+
19+
5.4:
20+
type: pecl
21+
version: 4.0.11
22+
23+
5.3:
24+
type: pecl
25+
version: 4.0.11

php_modules/apcu/options.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
3+
# The name of the module
4+
name: apcu
5+
6+
# Exclude module build/installation for the following PHP versions
7+
exclude: [5.2]
8+
9+
# In order for this module to built correctly against all dependencies,
10+
# the following modules must have been built first.
11+
depends_build: []
12+
13+
# In order for this module to function correctly,
14+
# the following modules must be loaded before.
15+
depends_load: []
16+
17+
# Enable this module by default via php.ini for PHP cli command?
18+
enabled_php_cli: true
19+
20+
# Enable this module by default via php.ini for PHP-FPM?
21+
enabled_php_fpm: true

php_modules/apcu/test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+

0 commit comments

Comments
 (0)