Skip to content

Commit bfb18b1

Browse files
akrabatrabbah
authored andcommitted
PHP 7.4 runtime (#79)
* Add PHP 7.4 runtime to .travis.yml * Add PHP 7.4 runtime - PHP 7.4.0 - guzzlehttp/guzzle 6.5.0 - ramsey/uuid 3.9.1
1 parent c6595a2 commit bfb18b1

11 files changed

Lines changed: 416 additions & 5 deletions

File tree

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ deploy:
5050
on:
5151
branch: master
5252
repo: apache/openwhisk-runtime-php
53+
- provider: script
54+
script: "./tools/travis/publish.sh openwhisk 7.4 nightly"
55+
on:
56+
branch: master
57+
repo: apache/openwhisk-runtime-php
5358
env:
5459
global:
5560
- secure: AJZRyRO/ZkStfywAZVN8bk1YmQLHOTD37QdjBsw77CdqnW9Y+a7V3+wZD3W+obQrEhNR9spkKlMh+biE2HFoRwr/AZ3Pl0frzhlyzZXaLUgJMK7wfQzuFVVgjODs4ld2PrJRv5LibFwco9cosDYHe9xlqQ+/Yg/QaWZPK0rBS1UFBxHh1cOcIJ0N80vDXgZbqmH9nuE7W5GvNGzDg9p16w+u48a6UF7UVzf+RU/uR13q7LrAq/FD7dtdiHpamIw4MiGWhW/GZQrwZpzovfGFr365uEVWu+ssQJld+sbeVoN9ED6kOrfYTFg+l7+8cvjhkZ9LUWELK/zVFCu4wYmuhk6utUreBD5rzsfVQmt0Ups7ANIqVS0874CW6WdxO+wPx5Me5k3azXbLgk6mPt4hL0+nlUZ1ycP2rEN/RnL2r8UJAN3vdvL1nXrTTulwNLwS8U3Lc+4yEV+YHQR9c9pYdw3VPx1vNVjEQ34djeoiVxROueBDroZfP3Ft5IazQx4sGPHWfFS1yH5JD58S7YYlz8QEope+Cby1Sj4MUJIjqlT9UgQXq1UydzAWmQPcn81scfITTAWzKHvIXxKrffiVPwkMG67uaUiobd9tDYr+CWpuKXckOSuOi0CwRuGJKyc7lGQvW2zVg7uC56bA9LMD91HYCsRUbNuOox9TXVLjGtM=

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@
2424

2525
## PHP versions
2626

27-
This runtime provides PHP 7.3 & 7.2.
27+
This runtime provides PHP 7.4, 7.3 & 7.2.
2828

2929
### Give it a try today
3030
To use as a docker action
3131

32+
PHP 7.4:
33+
```
34+
wsk action update myAction myAction.php --docker openwhisk/action-php-v7.4:latest
35+
```
36+
3237
PHP 7.3:
3338
```
3439
wsk action update myAction myAction.php --docker openwhisk/action-php-v7.3:latest
@@ -44,6 +49,11 @@ This works on any deployment of Apache OpenWhisk
4449
### To use on deployment that contains the runtime as a kind
4550
To use as a kind action
4651

52+
PHP 7.4:
53+
```
54+
wsk action update myAction myAction.php --kind php:7.4
55+
```
56+
4757
PHP 7.3:
4858
```
4959
wsk action update myAction myAction.php --kind php:7.3
@@ -56,19 +66,21 @@ wsk action update myAction myAction.php --kind php:7.2
5666

5767
### Local development
5868
```
69+
./gradlew core:php7.4Action:distDocker
5970
./gradlew core:php7.3Action:distDocker
6071
./gradlew core:php7.2Action:distDocker
6172
```
62-
This will produce the images `whisk/action-php-v7.3` & `whisk/action-php-v7.2`
73+
This will produce the images `whisk/action-php-v7.4`, `whisk/action-php-v7.3` & `whisk/action-php-v7.2` respectively.
6374

6475
Build and Push image
6576
```
6677
docker login
78+
./gradlew core:php7.4Action:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io
6779
./gradlew core:php7.3Action:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io
6880
./gradlew core:php7.2Action:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io
6981
```
7082

71-
Deploy OpenWhisk using ansible environment that contains the kinds `php:7.3` & `php:7.2`
83+
Deploy OpenWhisk using ansible environment that contains the kinds `php:7.4`, `php:7.3` & `php:7.2`
7284
Assuming you have OpenWhisk already deploy locally and `OPENWHISK_HOME` pointing to root directory of OpenWhisk core repository.
7385

7486
Set `ROOTDIR` to the root directory of this repository.
@@ -92,7 +104,11 @@ wskdev fresh -t local-php
92104

93105
To use as docker action push to your own dockerhub account
94106
```
95-
docker tag whisk/php7.2Action $user_prefix/action-php-v7.3
107+
docker tag whisk/php7.4Action $user_prefix/action-php-v7.4
108+
docker push $user_prefix/action-php-v7.3
109+
```
110+
```
111+
docker tag whisk/php7.3Action $user_prefix/action-php-v7.3
96112
docker push $user_prefix/action-php-v7.3
97113
```
98114
```
@@ -102,7 +118,7 @@ docker push $user_prefix/action-php-v7.2
102118

103119
Then create the action using your the image from dockerhub
104120
```
105-
wsk action update myAction myAction.php --docker $user_prefix/action-php-v7.3
121+
wsk action update myAction myAction.php --docker $user_prefix/action-php-v7.4
106122
```
107123
The `$user_prefix` is usually your dockerhub user id.
108124

core/php7.4Action/CHANGELOG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!--
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
-->
19+
## Apache 1.14.0 (next release)
20+
21+
Initial release
22+
23+
- Added: PHP: 7.4.0
24+
- Added: PHP extensions in addition to the standard ones:
25+
- bcmath
26+
- curl
27+
- gd
28+
- intl
29+
- mbstring
30+
- mysqli
31+
- pdo_mysql
32+
- pdo_pgsql
33+
- pdo_sqlite
34+
- soap
35+
- zip
36+
- mongo
37+
- Added: Composer packages:
38+
- [guzzlehttp/guzzle](https://packagist.org/packages/guzzlehttp/guzzle): 6.5.0
39+
- [ramsey/uuid](https://packagist.org/packages/ramsey/uuid): 3.9.1

core/php7.4Action/Dockerfile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
FROM golang:1.12 as builder
19+
RUN env CGO_ENABLED=0 go get github.com/apache/openwhisk-runtime-go/main && mv /go/bin/main /bin/proxy
20+
#ENV PROXY_SOURCE=https://github.com/apache/openwhisk-runtime-go/archive/golang1.11@1.13.0-incubating.tar.gz
21+
#RUN curl -L "$PROXY_SOURCE" | tar xzf - \
22+
# && mkdir -p src/github.com/apache \
23+
# && mv openwhisk-runtime-go-golang1.11-1.13.0-incubating \
24+
# src/github.com/apache/incubator-openwhisk-runtime-go \
25+
# && cd src/github.com/apache/incubator-openwhisk-runtime-go/main \
26+
# && CGO_ENABLED=0 go build -o /bin/proxy
27+
28+
FROM php:7.4.0-cli-buster
29+
30+
# install dependencies
31+
RUN \
32+
apt-get -y update && \
33+
apt-get -y install \
34+
libfreetype6-dev \
35+
libicu-dev \
36+
libicu63 \
37+
libjpeg-dev \
38+
libpng-dev \
39+
libssl-dev \
40+
libxml2-dev \
41+
libzip-dev \
42+
postgresql-server-dev-11 \
43+
unzip \
44+
zlib1g-dev
45+
46+
# Install useful PHP extensions
47+
RUN \
48+
docker-php-ext-install \
49+
bcmath \
50+
gd \
51+
intl \
52+
mysqli \
53+
opcache \
54+
pdo_mysql \
55+
pdo_pgsql \
56+
soap \
57+
zip \
58+
&& pecl install mongodb \
59+
&& docker-php-ext-enable mongodb
60+
61+
COPY php.ini /usr/local/etc/php
62+
63+
# install composer
64+
RUN curl -s -f -L -o /tmp/installer.php https://getcomposer.org/installer \
65+
&& php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer \
66+
&& composer --ansi --version --no-interaction --no-plugins --no-scripts
67+
68+
# install default Composer dependencies
69+
RUN mkdir -p /phpAction/composer
70+
COPY composer.json /phpAction/composer
71+
RUN cd /phpAction/composer && /usr/bin/composer install --no-plugins --no-scripts --prefer-dist --no-dev -o && rm composer.lock
72+
73+
# install proxy binary alogn with compile and launcher scripts
74+
RUN mkdir -p /phpAction/action
75+
WORKDIR /phpAction
76+
COPY --from=builder /bin/proxy /bin/proxy
77+
ADD compile /bin/compile
78+
ADD runner.php /bin/runner.php
79+
ENV OW_COMPILER=/bin/compile
80+
81+
ENTRYPOINT [ "/bin/proxy" ]

core/php7.4Action/build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
ext.dockerImageName = 'action-php-v7.4'
19+
apply from: '../../gradle/docker.gradle'

core/php7.4Action/compile

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env php
2+
<?php
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership.
7+
* The ASF licenses this file to You under the Apache License, Version 2.0
8+
* (the "License"); you may not use this file except in compliance with
9+
* the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
/**
21+
* compile
22+
*
23+
* This file is launched by the action proxy.
24+
* It copies runner.php to right source directory and creates a bash exec script
25+
* that the action proxy will call to start everything off
26+
*/
27+
28+
main($argc, $argv);
29+
exit;
30+
31+
function main($argc, $argv)
32+
{
33+
if ($argc < 4) {
34+
print("usage: <main-function-name> <source-dir> <bin-dir>");
35+
exit(1);
36+
}
37+
$main = $argv[1];
38+
$src = realpath($argv[2]);
39+
$bin = realpath($argv[3]);
40+
41+
$shim = $bin.'/exec';
42+
43+
sources($src);
44+
build($shim, $src, $main);
45+
}
46+
47+
/**
48+
* Sort out the source code
49+
*
50+
* 1. Copy src/exec to src/index.php if necessary
51+
* 2. Ensure vendor directory exists
52+
*/
53+
function sources(string $src)
54+
{
55+
// If the file uploaded by the user is a plain PHP file, then
56+
// the filename will be called exec by the action proxy.
57+
// Rename it to index.php
58+
if (file_exists($src . '/exec')) {
59+
rename($src . '/exec', $src . '/index.php');
60+
}
61+
62+
// put vendor in the right place if it doesn't exist
63+
if (!is_dir($src . '/vendor')) {
64+
exec('cp -a /phpAction/composer/vendor ' . escapeshellarg($src . '/vendor'));
65+
}
66+
}
67+
68+
/**
69+
* Create bin/exec shim
70+
*/
71+
function build(string $shim, string $src, string $main) : void
72+
{
73+
$contents = <<<EOT
74+
#!/bin/bash
75+
cd $src
76+
exec php -f /bin/runner.php -- "$main"
77+
78+
EOT;
79+
80+
file_put_contents($shim, $contents);
81+
chmod($shim, 0755);
82+
}

core/php7.4Action/composer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"config": {
3+
"platform": {
4+
"php": "7.3"
5+
}
6+
},
7+
"require": {
8+
"guzzlehttp/guzzle": "6.5.0",
9+
"ramsey/uuid": "3.9.1"
10+
}
11+
}

core/php7.4Action/php.ini

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
; Licensed to the Apache Software Foundation (ASF) under one or more
2+
; contributor license agreements. See the NOTICE file distributed with
3+
; this work for additional information regarding copyright ownership.
4+
; The ASF licenses this file to You under the Apache License, Version 2.0
5+
; (the "License"); you may not use this file except in compliance with
6+
; the License. You may obtain a copy of the License at
7+
;
8+
; http://www.apache.org/licenses/LICENSE-2.0
9+
;
10+
; Unless required by applicable law or agreed to in writing, software
11+
; distributed under the License is distributed on an "AS IS" BASIS,
12+
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
; See the License for the specific language governing permissions and
14+
; limitations under the License.
15+
16+
[PHP]
17+
short_open_tag = Off
18+
output_buffering = Off
19+
expose_php = Off
20+
max_execution_time = 0
21+
memory_limit = -1
22+
error_reporting = E_ALL
23+
display_errors = Off
24+
log_errors = On
25+
log_errors_max_len = 0
26+
html_errors = Off
27+
variables_order = "EGPCS"
28+
request_order = "GP"
29+
post_max_size = 0
30+
enable_dl = Off
31+
zend.assertions = -1
32+
33+
[opcache]
34+
opcache.enable=1
35+
opcache.enable_cli=1
36+
opcache.max_accelerated_files=7963
37+
opcache.validate_timestamps=0

0 commit comments

Comments
 (0)