Skip to content

Commit 392f52f

Browse files
authored
Add PHP 8.0 runtime (#95)
* Add PHP 8.0 Add a runtime for PHP 8.0. Update the dependencies to the latest versions. * Fix "non-default entry point" test In PHP, string array keys need to be quoted. This generated a notice in PHP 7, but in PHP 8 it errors. * Reduce size of PHP 8 container Uninstall dev dependencies to make the container smaller. * Remove unneeded source code This is not needed after build and makes the container much smaller.
1 parent cd48ef1 commit 392f52f

12 files changed

Lines changed: 443 additions & 5 deletions

File tree

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ deploy:
5151
on:
5252
branch: master
5353
repo: apache/openwhisk-runtime-php
54+
- provider: script
55+
script: "./tools/travis/publish.sh openwhisk 8.0 nightly"
56+
on:
57+
branch: master
58+
repo: apache/openwhisk-runtime-php
5459
env:
5560
global:
5661
- 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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@
2424

2525
## PHP versions
2626

27-
This runtime provides PHP 7.4 and 7.3.
27+
This runtime provides PHP 8.0, 7.4 and 7.3.
2828

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

32+
PHP 8.0:
33+
```
34+
wsk action update myAction myAction.php --docker openwhisk/action-php-v8.0:latest
35+
```
36+
3237
PHP 7.4:
3338
```
3439
wsk action update myAction myAction.php --docker openwhisk/action-php-v7.4: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 8.0:
53+
```
54+
wsk action update myAction myAction.php --kind php:8.0
55+
```
56+
4757
PHP 7.4:
4858
```
4959
wsk action update myAction myAction.php --kind php:7.4
@@ -55,20 +65,23 @@ wsk action update myAction myAction.php --kind php:7.3
5565
```
5666

5767
### Local development
68+
5869
```
70+
./gradlew core:php8.0Action:distDocker
5971
./gradlew core:php7.4Action:distDocker
6072
./gradlew core:php7.3Action:distDocker
6173
```
62-
This will produce the images `whisk/action-php-v7.4` & `whisk/action-php-v7.3` respectively.
74+
This will produce the images `whisk/action-php-v8.0`, `whisk/action-php-v7.4` & `whisk/action-php-v7.3` respectively.
6375

6476
Build and Push image
6577
```
6678
docker login
79+
./gradlew core:php8.0Action:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io
6780
./gradlew core:php7.4Action:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io
6881
./gradlew core:php7.3Action:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io
6982
```
7083

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

7487
Set `ROOTDIR` to the root directory of this repository.
@@ -92,6 +105,10 @@ wskdev fresh -t local-php
92105

93106
To use as docker action push to your own dockerhub account
94107
```
108+
docker tag whisk/php8.0Action $user_prefix/action-php-v8.0
109+
docker push $user_prefix/action-php-v8.0
110+
```
111+
```
95112
docker tag whisk/php7.4Action $user_prefix/action-php-v7.4
96113
docker push $user_prefix/action-php-v7.4
97114
```
@@ -102,7 +119,7 @@ docker push $user_prefix/action-php-v7.3
102119

103120
Then create the action using your the image from dockerhub
104121
```
105-
wsk action update myAction myAction.php --docker $user_prefix/action-php-v7.4
122+
wsk action update myAction myAction.php --docker $user_prefix/action-php-v8.0
106123
```
107124
The `$user_prefix` is usually your dockerhub user id.
108125

core/php8.0Action/CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
## Next Release
20+
Initial release
21+
- Added: PHP: 8.0.1
22+
- Added: PHP extensions in addition to the standard ones:
23+
- bcmath
24+
- curl
25+
- gd
26+
- intl
27+
- mbstring
28+
- mysqli
29+
- pdo_mysql
30+
- pdo_pgsql
31+
- pdo_sqlite
32+
- soap
33+
- zip
34+
- mongo
35+
- Added: Composer packages:
36+
- [guzzlehttp/guzzle](https://packagist.org/packages/guzzlehttp/guzzle): 7.2.0
37+
- [ramsey/uuid](https://packagist.org/packages/ramsey/uuid): 4.1.1

core/php8.0Action/Dockerfile

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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+
# build go proxy from source
19+
FROM golang:1.15 AS builder_source
20+
RUN env CGO_ENABLED=0 go get github.com/apache/openwhisk-runtime-go/main && mv /go/bin/main /bin/proxy
21+
22+
# or build it from a release
23+
FROM golang:1.15 AS builder_release
24+
ARG GO_PROXY_RELEASE_VERSION=1.15@1.16.0
25+
RUN curl -sL \
26+
https://github.com/apache/openwhisk-runtime-go/archive/{$GO_PROXY_RELEASE_VERSION}.tar.gz\
27+
| tar xzf -\
28+
&& cd openwhisk-runtime-go-*/main\
29+
&& GO111MODULE=on go build -o /bin/proxy
30+
31+
FROM php:8.0.1-cli-buster
32+
33+
# select the builder to use
34+
ARG GO_PROXY_BUILD_FROM=release
35+
36+
# install PHP extensions
37+
RUN apt-get -y update \
38+
&& apt-get -y install --no-install-recommends \
39+
unzip \
40+
libfreetype6 \
41+
libicu63 \
42+
libjpeg62-turbo \
43+
libpng16-16 \
44+
libssl1.1 \
45+
libxml2 \
46+
libzip4 \
47+
libpq5 \
48+
\
49+
libfreetype6-dev \
50+
libicu-dev \
51+
libjpeg-dev \
52+
libpng-dev \
53+
libssl-dev \
54+
libxml2-dev \
55+
libzip-dev \
56+
postgresql-server-dev-11 \
57+
\
58+
&& docker-php-ext-install \
59+
bcmath \
60+
gd \
61+
intl \
62+
mysqli \
63+
opcache \
64+
pdo_mysql \
65+
pdo_pgsql \
66+
soap \
67+
zip \
68+
\
69+
&& mkdir -p /usr/src/php/ext/mongodb \
70+
&& curl -fsSL https://pecl.php.net/get/mongodb-1.9.0RC1 | tar xvz -C "/usr/src/php/ext/mongodb" --strip 1 \
71+
&& docker-php-ext-install -j$(nproc) mongodb \
72+
\
73+
&& apt-get purge -y --auto-remove $PHPIZE_DEPS \
74+
&& apt-get purge -y --auto-remove libclang-common-7-dev clang-7 llvm-7 llvm-7-dev \
75+
&& apt-get purge -y --auto-remove libfreetype6-dev \
76+
libicu-dev \
77+
libjpeg-dev \
78+
libpng-dev \
79+
libssl-dev \
80+
libxml2-dev \
81+
libzip-dev \
82+
postgresql-server-dev-11 \
83+
&& apt-get autoremove -y \
84+
&& apt-get clean -y \
85+
&& rm -rf /usr/src/php
86+
87+
COPY php.ini /usr/local/etc/php
88+
89+
# install composer
90+
RUN curl -s -f -L -o /tmp/installer.php https://getcomposer.org/installer \
91+
&& php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer \
92+
&& composer --ansi --version --no-interaction --no-plugins --no-scripts
93+
94+
# install default Composer dependencies
95+
RUN mkdir -p /phpAction/composer
96+
COPY composer.json /phpAction/composer
97+
RUN cd /phpAction/composer && /usr/bin/composer install --no-plugins --no-scripts --prefer-dist --no-dev -o && rm composer.lock
98+
99+
# install proxy binary along with compile and launcher scripts
100+
RUN mkdir -p /phpAction/action
101+
WORKDIR /phpAction
102+
COPY --from=builder_source /bin/proxy /bin/proxy_source
103+
COPY --from=builder_release /bin/proxy /bin/proxy_release
104+
RUN mv /bin/proxy_${GO_PROXY_BUILD_FROM} /bin/proxy
105+
ADD compile.php /bin/compile.php
106+
ADD runner.php /bin/runner.php
107+
ENV OW_COMPILER=/bin/compile.php
108+
109+
ENTRYPOINT [ "/bin/proxy" ]

core/php8.0Action/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-v8.0'
19+
apply from: '../../gradle/docker.gradle'

core/php8.0Action/compile.php

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/php8.0Action/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": "8.0"
5+
}
6+
},
7+
"require": {
8+
"guzzlehttp/guzzle": "7.2.0",
9+
"ramsey/uuid": "4.1.1"
10+
}
11+
}

core/php8.0Action/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)