Skip to content

Commit 6afeae0

Browse files
committed
Adding blackfire and xdebug
1 parent ad3f1db commit 6afeae0

File tree

9 files changed

+189
-24
lines changed

9 files changed

+189
-24
lines changed

.travis.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ env:
1111
- LAYER=amqp PHP=72
1212
- LAYER=amqp PHP=73
1313
- LAYER=amqp PHP=74
14-
- LAYER=mecached PHP=72
15-
- LAYER=mecached PHP=73
16-
- LAYER=mecached PHP=74
14+
- LAYER=blackfire PHP=72
15+
- LAYER=blackfire PHP=73
16+
- LAYER=blackfire PHP=74
17+
- LAYER=xdebug PHP=72
18+
- LAYER=xdebug PHP=73
19+
- LAYER=xdebug PHP=74
1720

1821
script:
19-
- cd layer/$LAYER
22+
- cd layers/$LAYER
2023
- docker build --build-arg PHP_VERSION=$PHP .

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SHELL := /bin/bash
22
php_versions = 72 73 74
3-
php_versions = 73
3+
44

55
docker-images:
66
PWD=pwd
@@ -10,23 +10,24 @@ docker-images:
1010
echo "###############################################"; \
1111
echo "### Building $${dir} PHP$${php_version}"; \
1212
echo "###"; \
13-
cd ${PWD} ; cd $${dir} ; docker build -t bref/$${dir}-php-$${php_version} --build-arg PHP_VERSION=$${php_version} ${DOCKER_BUILD_FLAGS} . ; \
13+
cd ${PWD} ; cd $${dir} ; \
14+
docker build -t bref/$${dir}-php-$${php_version} --build-arg PHP_VERSION=$${php_version} ${DOCKER_BUILD_FLAGS} . ; \
1415
echo ""; \
1516
done \
1617
done
1718

1819
# The PHP runtimes
1920
layers: docker-images
2021
PWD=pwd
21-
rm -rf export/tmp export/layer-*.zip || true
22+
rm -rf export/layer-*.zip || true
2223
mkdir export/tmp
2324
for dir in layers/*; do \
2425
for php_version in $(php_versions); do \
2526
echo "###############################################"; \
2627
echo "###############################################"; \
2728
echo "### Exporting $${dir} PHP$${php_version}"; \
2829
echo "###"; \
29-
cd ${PWD} ; cd export/tmp ; \
30+
cd ${PWD} ; rm -rf export/tmp/* || true ; cd export/tmp ; \
3031
docker run --entrypoint "tar" bref/$${dir}-php-$${php_version} -ch -C /opt . | tar -x ; \
3132
zip --quiet -X --recurse-paths ../`echo "$${dir}-php-$${php_version}" | sed -e "s/layers\//layer-/g"`.zip . ; \
3233
echo ""; \

Readme.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# Bref extra layers
1+
# Bref Extra PHP Extension
22

3-
Create small layers with specific PHP extensions. This is useful when you want something "off the shelf".
4-
If you ever need more than one layer you should consider creating your own layer. That is because AWS has
5-
a limit of 5 layers per Lambda.
3+
This repository has some AWS Lambda layers with PHP extensions. This is useful when you want something "off the shelf".
4+
If you ever need more than 2-3 layer you should consider creating your own layer. That is because AWS has
5+
a limit of 5 layers per Lambda.
6+
7+
We are happy to get contributions for other extensions. Sky is the limit! (And also your knowledge with Docker...)
68

79
```yaml
810
# serverless.yml
@@ -15,22 +17,29 @@ provider:
1517

1618
plugins:
1719
- ./vendor/bref/bref
18-
- ./vendor/bref/extra-layers # Add the extra Serverless plugin
20+
- ./vendor/bref/extra-layers # <--- Add the extra Serverless plugin
1921

2022
functions:
2123
console:
2224
handler: bin/console
2325
layers:
24-
- ${bref:layer.php-73}
25-
- ${bref:extra.amqp-php-72} # AMQP layer
26+
- ${bref:layer.php-74}
27+
- ${bref:extra.amqp-php-74} # <----- Example for AMQP layer
2628
- ${bref:layer.console}
2729
```
2830
2931
```
3032
;php/conf.d/php.ini
31-
extension=amqp.so
33+
extension=/opt/bref-extra/amqp.so
3234
```
3335

36+
## Available layers
37+
38+
| Name | Serverless config (php 7.4) | php.ini config |
39+
| ---- | ----------------------------| -------------- |
40+
| AMQP | `${bref:extra.amqp-php-74}` | `extension=/opt/bref-extra/amqp.so` |
41+
| Blackfire | `${bref:extra.blackfire-php-74}` | `extension=/opt/bref-extra/blackfire.so` |
42+
| Xdebug | `${bref:extra.xdebug-php-74}` | `zend_extension=/opt/bref-extra/xdebug.so` |
3443

3544
## Deploy new versions
3645

checksums.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
{
2-
"memcached-php-73": "58d2102c602ff849734a57c255d70657",
3-
"amqp-php-73": "26446b9824c8bb7af006664437fb09b8"
2+
"blackfire-php-74": "d84b2d7f3e290237a40994e2d758fb05",
3+
"amqp-php-74": "a77a771d9fbdb85c3733be399fe1d674",
4+
"xdebug-php-74": "943b56db0f477f0be019318338f84dcb",
5+
"blackfire-php-72": "41ee2abc51d6645b451b1ca712b989eb",
6+
"blackfire-php-73": "b8c9548691e517c73aa9342fc17d7a85",
7+
"amqp-php-72": "5f7a99b816afb6f8135b0c03d047a45f",
8+
"xdebug-php-72": "44d5a532fcb4a54ac4d9b2d6f1337c92",
9+
"xdebug-php-73": "4918003f160dd65986f5247d283846d4",
10+
"amqp-php-73": "32a6249787c6d087a8d7f9ee1576cb51"
411
}

layers.json

Lines changed: 129 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,79 @@
11
{
2-
"memcached-php-73": {
2+
"blackfire-php-74": {
3+
"ca-central-1": 1,
4+
"eu-central-1": 1,
5+
"eu-north-1": 1,
6+
"eu-west-1": 1,
7+
"eu-west-2": 1,
8+
"eu-west-3": 1,
9+
"sa-east-1": 1,
10+
"us-east-1": 1,
11+
"us-east-2": 1,
12+
"us-west-1": 1,
13+
"us-west-2": 1,
14+
"ap-south-1": 1,
15+
"ap-northeast-1": 1,
16+
"ap-northeast-2": 1,
17+
"ap-southeast-1": 1,
18+
"ap-southeast-2": 1
19+
},
20+
"amqp-php-74": {
21+
"ca-central-1": 1,
22+
"eu-central-1": 1,
23+
"eu-north-1": 1,
24+
"eu-west-1": 1,
25+
"eu-west-2": 1,
26+
"eu-west-3": 1,
27+
"sa-east-1": 1,
28+
"us-east-1": 1,
29+
"us-east-2": 1,
30+
"us-west-1": 1,
31+
"us-west-2": 1,
32+
"ap-south-1": 1,
33+
"ap-northeast-1": 1,
34+
"ap-northeast-2": 1,
35+
"ap-southeast-1": 1,
36+
"ap-southeast-2": 1
37+
},
38+
"xdebug-php-74": {
39+
"ca-central-1": 1,
40+
"eu-central-1": 1,
41+
"eu-north-1": 1,
42+
"eu-west-1": 1,
43+
"eu-west-2": 1,
44+
"eu-west-3": 1,
45+
"sa-east-1": 1,
46+
"us-east-1": 1,
47+
"us-east-2": 1,
48+
"us-west-1": 1,
49+
"us-west-2": 1,
50+
"ap-south-1": 1,
51+
"ap-northeast-1": 1,
52+
"ap-northeast-2": 1,
53+
"ap-southeast-1": 1,
54+
"ap-southeast-2": 1
55+
},
56+
"blackfire-php-72": {
57+
"ca-central-1": 1,
58+
"eu-central-1": 1,
59+
"eu-north-1": 1,
60+
"eu-west-1": 1,
61+
"eu-west-2": 1,
62+
"eu-west-3": 1,
63+
"sa-east-1": 1,
64+
"us-east-1": 1,
65+
"us-east-2": 1,
66+
"us-west-1": 1,
67+
"us-west-2": 1,
68+
"ap-south-1": 1,
69+
"ap-northeast-1": 1,
70+
"ap-northeast-2": 1,
71+
"ap-southeast-1": 1,
72+
"ap-southeast-2": 1
73+
},
74+
"blackfire-php-73": {
375
"ca-central-1": 2,
4-
"eu-central-1": 3,
76+
"eu-central-1": 2,
577
"eu-north-1": 2,
678
"eu-west-1": 2,
779
"eu-west-2": 2,
@@ -17,7 +89,43 @@
1789
"ap-southeast-1": 2,
1890
"ap-southeast-2": 2
1991
},
20-
"amqp-php-73": {
92+
"amqp-php-72": {
93+
"ca-central-1": 1,
94+
"eu-central-1": 1,
95+
"eu-north-1": 1,
96+
"eu-west-1": 1,
97+
"eu-west-2": 1,
98+
"eu-west-3": 1,
99+
"sa-east-1": 1,
100+
"us-east-1": 1,
101+
"us-east-2": 1,
102+
"us-west-1": 1,
103+
"us-west-2": 1,
104+
"ap-south-1": 1,
105+
"ap-northeast-1": 1,
106+
"ap-northeast-2": 1,
107+
"ap-southeast-1": 1,
108+
"ap-southeast-2": 1
109+
},
110+
"xdebug-php-72": {
111+
"ca-central-1": 1,
112+
"eu-central-1": 1,
113+
"eu-north-1": 1,
114+
"eu-west-1": 1,
115+
"eu-west-2": 1,
116+
"eu-west-3": 1,
117+
"sa-east-1": 1,
118+
"us-east-1": 1,
119+
"us-east-2": 1,
120+
"us-west-1": 1,
121+
"us-west-2": 1,
122+
"ap-south-1": 1,
123+
"ap-northeast-1": 1,
124+
"ap-northeast-2": 1,
125+
"ap-southeast-1": 1,
126+
"ap-southeast-2": 1
127+
},
128+
"xdebug-php-73": {
21129
"ca-central-1": 3,
22130
"eu-central-1": 3,
23131
"eu-north-1": 3,
@@ -34,5 +142,23 @@
34142
"ap-northeast-2": 3,
35143
"ap-southeast-1": 3,
36144
"ap-southeast-2": 3
145+
},
146+
"amqp-php-73": {
147+
"ca-central-1": 4,
148+
"eu-central-1": 4,
149+
"eu-north-1": 4,
150+
"eu-west-1": 4,
151+
"eu-west-2": 4,
152+
"eu-west-3": 4,
153+
"sa-east-1": 4,
154+
"us-east-1": 4,
155+
"us-east-2": 4,
156+
"us-west-1": 4,
157+
"us-west-2": 4,
158+
"ap-south-1": 4,
159+
"ap-northeast-1": 4,
160+
"ap-northeast-2": 4,
161+
"ap-southeast-1": 4,
162+
"ap-southeast-2": 4
37163
}
38164
}

layers/amqp/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ RUN set -xe; \
1818
cmake --build . --target install
1919

2020
RUN pecl install amqp
21+
RUN cp /opt/bref/lib/php/extensions/no-debug-zts-*/amqp.so /tmp/amqp.so
2122

2223
# Build the final image from the lambci image that is close to the production environment
2324
FROM lambci/lambda:provided
@@ -34,4 +35,4 @@ COPY --from=ext /opt/bref/lib64/librabbitmq.so.4 /opt/bref/lib64/librabbitmq.so.
3435
COPY --from=ext /opt/bref/lib64/librabbitmq.so.4.3.0 /opt/bref/lib64/librabbitmq.so.4.3.0
3536
COPY --from=ext /opt/bref/lib64/pkgconfig/librabbitmq.pc /opt/bref/lib64/pkgconfig/librabbitmq.pc
3637

37-
COPY --from=ext /opt/bref/lib/php/extensions/no-debug-zts-20180731/amqp.so /opt/bref/lib/php/extensions/no-debug-zts-20180731/amqp.so
38+
COPY --from=ext /tmp/amqp.so /opt/bref-extra/amqp.so

layers/blackfire/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ARG PHP_VERSION
2+
FROM bref/build-php-$PHP_VERSION AS ext
3+
4+
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")-zts \
5+
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
6+
&& mkdir -p /tmp/blackfire \
7+
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
8+
&& cp /tmp/blackfire/blackfire-*.so /tmp/blackfire.so \
9+
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
10+
11+
12+
# Build the final image from the lambci image that is close to the production environment
13+
FROM lambci/lambda:provided
14+
15+
# Copy things we installed to the final image
16+
COPY --from=ext /tmp/blackfire.so /opt/bref-extra/blackfire.so
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
ARG PHP_VERSION
22
FROM bref/build-php-$PHP_VERSION AS ext
33

4-
RUN LD_LIBRARY_PATH= yum install -y php-pecl-memcached
4+
RUN pecl install xdebug
5+
RUN cp `php-config --extension-dir`/xdebug.so /tmp/xdebug.so
56

67
# Build the final image from the lambci image that is close to the production environment
78
FROM lambci/lambda:provided
89

910
# Copy things we installed to the final image
10-
COPY --from=ext /usr/lib64/php/modules/memcached.so /opt/bref/lib/php/extensions/no-debug-zts-20180731/memcached.so
11+
COPY --from=ext /tmp/xdebug.so /opt/bref-extra/xdebug.so

src/Command/PublishCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function __invoke(OutputInterface $output)
6363
exit(1);
6464
}
6565

66+
ksort($discoveredChecksums);
6667
// Dump checksums
6768
file_put_contents($this->projectDir.'/checksums.json', json_encode($discoveredChecksums, \JSON_PRETTY_PRINT));
6869

0 commit comments

Comments
 (0)