Skip to content

Commit 3a82859

Browse files
committed
Merge branch 'v2'
2 parents f858f5d + 9fccbad commit 3a82859

File tree

55 files changed

+331
-545
lines changed

Some content is hidden

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

55 files changed

+331
-545
lines changed

.github/workflows/blackfire.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
id: fetch_version
2727
run: |
2828
cd layers/blackfire;
29-
for VERSION in 73 74 80 81; do
29+
for VERSION in 80 81; do
3030
BF_AGENT_VERSION=$(curl -s -o probe -D - https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$VERSION | grep -i 'X-Blackfire-Release-Version: ' | sed "s%X-Blackfire-Release-Version: %%I" | sed s%.$%%);
3131
php ./store.php $VERSION $BF_AGENT_VERSION;
3232
done

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Change log
22

3+
## 2.0.0
4+
5+
## Breaking changes
6+
7+
- Just like Bref v2, support for PHP 7.3 and 7.4 was dropped. PHP 8.0 or greater is required.
8+
9+
## Internal changes
10+
11+
These internal changes will not impact most users, however we list them in case you have an advanced use case:
12+
13+
- The "bref-extra" PHP extensions are now installed in the official Bref directory for PHP extensions: `/opt/bref/extensions`. They were previously installed in `/opt/bref-extra`.
14+
315
## 0.12.5
416

517
### Added

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ SHELL := /bin/bash
22
layer ?= *
33
resolve_php_versions = $(or $(php_versions),`jq -r '.php | join(" ")' ${1}/config.json`)
44
resolve_tags = `./new-docker-tags.php $(DOCKER_TAG)`
5+
BREF_VERSION = 2
56
67
define build_docker_image
7-
docker build -t bref/${1}-php-${2} --build-arg PHP_VERSION=${2} ${DOCKER_BUILD_FLAGS} ${1}
8+
docker build -t bref/${1}-php-${2} --build-arg PHP_VERSION=${2} --build-arg BREF_VERSION=${BREF_VERSION} ${DOCKER_BUILD_FLAGS} ${1}
89
endef
910
1011
docker-images:

Readme.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ service: app
2121
provider:
2222
name: aws
2323
region: us-east-1
24-
runtime: provided.al2
2524

2625
plugins:
2726
- ./vendor/bref/bref
@@ -30,10 +29,9 @@ plugins:
3029
functions:
3130
console:
3231
handler: bin/console
32+
runtime: php-81
3333
layers:
34-
- ${bref:layer.php-81}
3534
- ${bref-extra:amqp-php-81} # <----- Example for AMQP layer
36-
- ${bref:layer.console}
3735
```
3836
3937
### Available layers
@@ -161,9 +159,8 @@ docker-compose.yml
161159
162160
Dockerfile-phpFpm
163161
```
164-
FROM bref/extra-mongodb-php-82 as mongodbextra
165162
FROM bref/php-82-fpm-dev
166-
COPY --from=mongodbextra /opt /opt
163+
COPY --from=bref/extra-mongodb-php-82 /opt /opt
167164
```
168165
169166
## For contributors and maintainers
@@ -172,7 +169,7 @@ COPY --from=mongodbextra /opt /opt
172169
173170
The idea is to start from bref/build-php-XX, install all libraries and extensions
174171
you want, then move all related files to `/opt`. Those files will be available in
175-
the same same location on the Lambda.
172+
the same location on the Lambda.
176173
177174
Note that one can't just move files/libraries around. Most of them are expected to
178175
be in their "standard" location.
@@ -195,7 +192,7 @@ make test
195192
layer=imagick make test
196193

197194
# Test a single layer on a single PHP version
198-
layer=imagick php_versions=74 make test
195+
layer=imagick php_versions=81 make test
199196
```
200197
201198
You can publish the layer in your AWS account to test it in AWS Lambda as well:
@@ -227,14 +224,14 @@ git push
227224
#### Config
228225
229226
You can also build only one specific layer by providing `layer=blackfire` to `make`.
230-
Same thing for some specific version(s) of php by providing `php_versions="73 74"` to `make`.
227+
Same thing for some specific version(s) of php by providing `php_versions="80 81"` to `make`.
231228
You can invoke both ways:
232229
233230
```shell
234231
# First way: make with named arguments
235-
make layer=gd php_versions=74
232+
make layer=gd php_versions=81
236233
# Second way: environment variables passed to make
237-
layer=blackfire php_versions=80 make
234+
layer=blackfire php_versions=81 make
238235
```
239236

240237
## Lambda layers in details

checksums.json

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,18 @@
11
{
2-
"amqp-php-73": "62d7818aae952cda723294c549f4fe2e",
3-
"amqp-php-74": "75f216839af0a7954508c0dfbe111ef2",
4-
"blackfire-php-73": "cddd48f0de242f95b2a4c9919111e63f",
5-
"blackfire-php-74": "02eb83348630a23281ad8a5f8050d7a3",
6-
"cassandra-php-73": "856f61c17a91fd801f342fe57d304a0f",
7-
"cassandra-php-74": "78865fc2551e11b0c7725aeda15c0463",
8-
"ds-php-73": "d7e766ac190ef7e73d73d205475f8aea",
9-
"ds-php-74": "bf75a8ba745dd1078b8385bdadc4b9d8",
102
"ds-php-80": "3ac724f1507a22a67299ac2d4f4bbda2",
11-
"gd-php-73": "34d3c9485a429de127dbca8fc482a22f",
12-
"gd-php-74": "ca873f4f60cd8704f8c42eaef28e971e",
133
"gd-php-80": "335e9a9a1ed3382c01293e4c0f13b5b2",
14-
"gmp-php-73": "b9af2bdb33760e39fd122e8b2b077255",
15-
"gmp-php-74": "d5e318c544bfd64074bd5a3c51b26a5d",
164
"gmp-php-80": "239d8bbdebd17c951a416fa1798692b7",
17-
"grpc-php-73": "ad4b288e5a2a5fe8a68d1d2e3f69e902",
18-
"grpc-php-74": "9969c30b4e82913dbe21243b55ecd616",
19-
"igbinary-php-73": "437902c68dc48cb2af42bb87eb710a09",
20-
"igbinary-php-74": "a5b236c3e07c4edb9bea571da52b9686",
215
"igbinary-php-80": "4c293f167ffa6a1ecc75b7d5c5a07013",
22-
"imagick-php-73": "c27620d1830353932bf145c938b5c53f",
23-
"imagick-php-74": "6d8a40d33fe0c59acfa41461a21ca73d",
246
"imagick-php-80": "fc7c7e396565f1121077c59932ff285a",
25-
"imap-php-73": "c141e6bc9d7c5fc54054df54fdba9f48",
26-
"imap-php-74": "ed66daf477e5ba479326774f080c4d87",
27-
"ldap-php-73": "f759f8b488b6f1643fe9081658e7560a",
28-
"ldap-php-74": "b5bedc999d3d0aed235df293dcd410ed",
297
"ldap-php-80": "4af191177c16dfa221567b338eb58815",
30-
"mailparse-php-73": "f49f0b66c0db338fab8e56577e5ad10d",
31-
"mailparse-php-74": "702aafe062cea83884c74cecf2c69fad",
328
"mailparse-php-80": "c27d4e271dcf873ff318b0d6eb940c51",
33-
"memcache-php-73": "711c4d269533d616b401a7d566e41b71",
34-
"memcache-php-74": "b87da75e0c31d0f18285a6a7fa9a4095",
359
"memcache-php-80": "c3ae49f188ccbb17f8498fad8e909a8f",
36-
"memcached-php-73": "c4f73f8f249c88b67fa02c4ce779a52e",
37-
"memcached-php-74": "8c55e19abce3d0a1129ae3760d51053d",
38-
"mongodb-php-73": "e82ff82226354fbcae68b74756b54288",
39-
"mongodb-php-74": "6566353f69bfab2dd21f4c6835255d8d",
4010
"mongodb-php-80": "23c388c85a95e637ddce66d69af2cc2d",
41-
"msgpack-php-73": "dbe21d378313821d63ef61d27a782105",
42-
"msgpack-php-74": "9135bd160a9105d2a11fea58679a5f95",
43-
"newrelic-php-73": "ac551418182cb06319b7bcb480d7bc5d",
44-
"newrelic-php-74": "46e860d2654a02191b10178f4ee2edd1",
45-
"odbc-snowflake-php-73": "7ed04eb4497e0d4ef039d7d94d807179",
46-
"odbc-snowflake-php-74": "d965793a15654afe08bd40e252e1e029",
4711
"odbc-snowflake-php-80": "431007abb1ea2e3dc26c748311f3e023",
48-
"pcov-php-73": "57668c70f6c1e38ddd65496fb9bf2af1",
49-
"pcov-php-74": "6520eddb62ba44cb890a75094dd469be",
5012
"pcov-php-80": "c631e6947dd69b4f703844aa8f017497",
51-
"pgsql-php-73": "d4954f4784a162725336212dd3ae451a",
52-
"pgsql-php-74": "82a1fda19ed497b7eca72da6c9ccdbca",
5313
"pgsql-php-80": "a8983cf4f4e255f9f49bf13becf9d9d9",
54-
"redis-php-73": "6c5a727445ae3551bc91c4c9735fcb2c",
55-
"redis-php-74": "788c19584d1c6c58cb32245219727efd",
5614
"redis-php-80": "b33bb5ad2fa07e325b972d6759b482bf",
57-
"scrypt-php-73": "659640c1633cc28f5259bf189cfb5f46",
58-
"scrypt-php-74": "f946cee8f6b9ae9de5f4d4465621da7e",
59-
"sqlsrv-php-73": "31dcf086af0ef509f0dc6e72708a60ca",
60-
"sqlsrv-php-74": "757c92ade582cdbdec90b6e06db31daa",
61-
"uuid-php-73": "04f1d6061082bd3cb502245ee83338c4",
62-
"uuid-php-74": "ec21632672422d72a1e57f92ebf84508",
6315
"uuid-php-80": "8326ea5beb0a64dbda618af5de9a9b37",
64-
"xdebug-php-73": "db4333638a7b701d05c42a20485bea70",
65-
"xdebug-php-74": "787d7984d239798ee91839d19b58e801",
6616
"xdebug-php-80": "87cce18a36803f9b850e5c4e0f5791cb",
67-
"yaml-php-73": "338da4e5f5b0ec10ba59779ec6645c5e",
68-
"yaml-php-74": "9a4c6a491aea61a1043bcf8b8f24e041",
6917
"yaml-php-80": "6d3b1b4eec7e5667a80849a6feb742a3"
70-
}
18+
}

docs/create_your_own_extension_layer.md

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ FROM scratch
2828
```
2929

3030
The environment variable `PHP_VERSION` is passed from the Makefile as an argument
31-
to docker build. It may have values like: `73`, `74`, `80`. A docker image is created
31+
to docker build. It may have values like: `80`, `81`. A docker image is created
3232
for each `PHP_VERSION`. If the build procedure of your extension differs for each version,
3333
you may use this variable to switch processing in Dockerfile.
3434

35-
There are some other env variables available,`PHP_BUILD_DIR` is `/tmp/build/php`, `INSTALL_DIR` is `/opt/bref`.
35+
There are some other env variables available, like `PHP_BUILD_DIR` or `INSTALL_DIR`.
3636

3737
### Building your extension
3838

@@ -47,6 +47,8 @@ RUN ./configure --with-pgsql=${INSTALL_DIR}
4747
RUN make -j `nproc` && make install
4848

4949
RUN cp `php-config --extension-dir`/pgsql.so /tmp/pgsql.so
50+
RUN echo 'extension=pgsql.so' > /tmp/ext.ini
51+
RUN php /bref/lib-copy/copy-dependencies.php /tmp/pgsql.so /tmp/extension-libs
5052
```
5153

5254
You may need to:
@@ -57,19 +59,23 @@ You may need to:
5759

5860
The Dockerfiles for [these](../layers) extensions could be very helpful.
5961

62+
> **Note**
63+
> The `/bref/lib-copy/copy-dependencies.php` script will automatically copy system dependencies (libraries) used by the extension provided as a first argument.
64+
6065
### Copy files
6166

6267
The final extension layer is just a zip archive of files that overlay the PHP layer.
6368
The extension and all related files that need to be installed should be placed `/opt`
6469
directory in the final image.
6570

6671
```Dockerfile
67-
RUN echo 'extension=/opt/bref-extra/pgsql.so' > /tmp/ext.ini
72+
RUN echo 'extension=pgsql.so' > /tmp/ext.ini
6873

6974
FROM scratch
7075

71-
COPY --from=ext /tmp/pgsql.so /opt/bref-extra/pgsql.so
76+
COPY --from=ext /tmp/pgsql.so /opt/bref/extensions/pgsql.so
7277
COPY --from=ext /tmp/ext.ini /opt/bref/etc/php/conf.d/ext-pgsql.ini
78+
COPY --from=ext /tmp/extension-libs /opt/lib
7379
```
7480

7581
### Making a layer
@@ -96,7 +102,7 @@ $ make layers
96102
Register the zip file generated above to AWS as Lambda Layer. It also able to add from AWS console.
97103

98104
```bash
99-
$ aws lambda publish-layer-version --layer-name pgsql-php-73 --zip-file fileb://./export/layer-pgsql-php-73.zip
105+
$ aws lambda publish-layer-version --layer-name pgsql-php-80 --zip-file fileb://./export/layer-pgsql-php-80.zip
100106
```
101107

102108
# Test layers
@@ -118,10 +124,9 @@ $ composer init
118124
$ composer require bref/bref
119125
$ vendor/bin/bref init
120126
What kind of lambda do you want to create? (you will be able to add more functions later by editing `serverless.yml`) [PHP function]:
121-
[0] PHP function
122-
[1] HTTP application
123-
[2] Console application
124-
> 1
127+
[0] Web application
128+
[1] PHP function
129+
> 0
125130
## Select suitable for check your extension.
126131
```
127132

@@ -134,7 +139,7 @@ provider:
134139
name: aws
135140
- region: us-east-1
136141
+ region: <YOUR AWS REGION>
137-
runtime: provided
142+
runtime: provided.al2
138143

139144
plugins:
140145
- ./vendor/bref/bref
@@ -145,33 +150,25 @@ functions:
145150
description: ''
146151
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
147152
layers:
148-
- ${bref:layer.php-73-fpm}
149-
+ - arn:aws:lambda:<YOUR AWS REGION>:<YOUR AWS ID>:layer:pgsql-php-73:3
153+
- ${bref:layer.php-80-fpm}
154+
+ - arn:aws:lambda:<YOUR AWS REGION>:<YOUR AWS ID>:layer:pgsql-php-80:3
150155

151156
events:
152-
- http: 'ANY /'
153-
- http: 'ANY /{proxy+}'
157+
- httpApi: '*'
154158
```
155159

156-
Update `index.php` to be allowed you to check the extension.
160+
Update `index.php` to check that the extension is automatically loaded and works.
157161

158162
```diff
159163
<?php
160164

161165
- echo "Hello World";
162166
+ #
163-
+ # Add some check processing
167+
+ # Check the extension works
164168
+ #
165169
```
166170

167-
Add a setting to load the extension.
168-
169-
```bash
170-
$ mkdir -p php/conf.d
171-
$ echo "extension=/opt/bref-extra/pgsql.so" > php/conf.d/pgsql.ini
172-
```
173-
174-
Finally deploy and test this function.
171+
Finally, deploy and test this function.
175172

176173
```bash
177174
$ serverless deploy
@@ -188,15 +185,15 @@ In order to contribute, you should do a little more work.
188185
```diff
189186
### Available layers
190187

191-
| Name | Serverless config (php 7.4) | php.ini config |
192-
| ---- | ----------------------------| -------------- |
193-
| AMQP | `${bref-extra:amqp-php-74}` | `extension=/opt/bref-extra/amqp.so` |
194-
| Blackfire | `${bref-extra:blackfire-php-74}` | `extension=/opt/bref-extra/blackfire.so` |
195-
| GMP | `${bref-extra:gmp-php-74}` | `extension=/opt/bref-extra/gmp.so` |
196-
| Memcache | `${bref-extra:memcached-php-74}` | `extension=/opt/bref-extra/memcache.so` |
197-
| Memcached | `${bref-extra:memcached-php-74}` | `extension=/opt/bref-extra/memcached.so` |
198-
+| PostgreSQL | `${bref-extra:pgsql-php-74}` | `extension=/opt/bref-extra/pgsql.so` |
199-
| Xdebug | `${bref-extra:xdebug-php-74}` | `zend_extension=/opt/bref-extra/xdebug.so` |
188+
| Name | Serverless config (php 8.1) |
189+
| ---- | ----------------------------|
190+
| AMQP | `${bref-extra:amqp-php-81}` |
191+
| Blackfire | `${bref-extra:blackfire-php-81}` |
192+
| GMP | `${bref-extra:gmp-php-81}` |
193+
| Memcache | `${bref-extra:memcached-php-81}` |
194+
| Memcached | `${bref-extra:memcached-php-81}` |
195+
+| PostgreSQL | `${bref-extra:pgsql-php-81}` |
196+
| Xdebug | `${bref-extra:xdebug-php-81}` |
200197

201198
Note that the "Memcached" layer provides both extension for [Memcache](https://pecl.php.net/package/memcache) and [Memcached](https://pecl.php.net/package/memcached).
202199
```

0 commit comments

Comments
 (0)