Skip to content

Commit a4988be

Browse files
skywalkeretwLuke Roy
andauthored
Add php 8.1 Runtime (#122)
* Add php 8.1 Runtime * Install libicu57 and postgresql-server-dev-13 as log version no loger supported in debian bullseye * Install latest version of mongodb (1.14.0) * Add minor tweaks suggested by akrabat Co-authored-by: Luke Roy <lukeroy@Lukes-MacBook-Pro.local>
1 parent c587ae4 commit a4988be

11 files changed

Lines changed: 445 additions & 3 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.1 nightly"
56+
on:
57+
branch: master
58+
repo: apache/openwhisk-runtime-php
5459
env:
5560
global:
5661
- secure: "CE5mw5ZiXzchr1HcQVr94H8vN8U8Q/te0nPfWgEOUEbFixTRe71RYEKBHno/WztZd36XO1B3/1Ewc37FayFw474FUUdnrkVKh1ctzpmtBhGHw7KTMmSnICcR7ULcN/+WyjzvU5fTNMKEoaLcAcg4qEVqxnN4m3R1E8XJL9c0Kc8Hs2Mry0QqY9meX/DHeYzgs1VUuO/i0mXeXU6U8woP+eeGypaNrWk/U8gR9nA4VB49EVZZ1d8TtdaC9/+wmMjl93YQZccs1K2NTNJfDDU9Tm5RQQeXM4oZYaOaHvdlpo+iWhJ4blyVqY9i6NIx6satm5zV5amfO/hISuyfYdiyA/IiTvbewE4cUMq5W7B2xOUESmZQFqn4ssnCjKRGw2km2VnnAAQOSGMgQ1jUZUOYqtxKjTMYTtM8cZqYdo6URJy6Qz4Lhg/xfQgXdrPZZoKIoo4NcESHLaTfxazEB3nePA91qg4BxP3SHG0PcHtPm7fdj4RwlsMaIrPim5Kcz/Qpf2qSMO9ExhhtXKPMTzfAzanyQ6mMSgYjLhP7US6bESRsnf78PWvvo6krOkaZtxw+RricOg3YsTrs/6UudzZ1sT87NBbEjXy6sm7lKtcDTqfQAyrE+iMhdggSaivvpY03i0cBp3oqdoyLyAv/Usx4lGO0DuVX7gk8lO4aH2b16CI="

README.md

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

2525
## PHP versions
2626

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

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

32+
PHP 8.1:
33+
```
34+
wsk action update myAction myAction.php --docker openwhisk/action-php-v8.1:latest
35+
```
36+
3237
PHP 8.0:
3338
```
3439
wsk action update myAction myAction.php --docker openwhisk/action-php-v8.0: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.1:
53+
```
54+
wsk action update myAction myAction.php --kind php:8.1
55+
```
56+
4757
PHP 8.0:
4858
```
4959
wsk action update myAction myAction.php --kind php:8.0
@@ -57,10 +67,11 @@ wsk action update myAction myAction.php --kind php:7.4
5767
### Local development
5868

5969
```
70+
./gradlew core:php8.1Action:distDocker
6071
./gradlew core:php8.0Action:distDocker
6172
./gradlew core:php7.4Action:distDocker
6273
```
63-
This will produce the images `whisk/action-php-v8.0` and `whisk/action-php-v7.4` respectively.
74+
This will produce the images `whisk/action-php-v8.1`, `whisk/action-php-v8.0` and `whisk/action-php-v7.4` respectively.
6475

6576
Build and Push image
6677
```
@@ -69,7 +80,7 @@ docker login
6980
./gradlew core:php7.4Action:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io
7081
```
7182

72-
Deploy OpenWhisk using ansible environment that contains the kinds `php:8.0` and `php:7.4`
83+
Deploy OpenWhisk using ansible environment that contains the kinds `php:8.1`, `php:8.0` and `php:7.4`
7384
Assuming you have OpenWhisk already deploy locally and `OPENWHISK_HOME` pointing to root directory of OpenWhisk core repository.
7485

7586
Set `ROOTDIR` to the root directory of this repository.
@@ -93,6 +104,10 @@ wskdev fresh -t local-php
93104

94105
To use as docker action push to your own dockerhub account
95106
```
107+
docker tag whisk/php8.1Action $user_prefix/action-php-v8.1
108+
docker push $user_prefix/action-php-v8.1
109+
```
110+
```
96111
docker tag whisk/php8.0Action $user_prefix/action-php-v8.0
97112
docker push $user_prefix/action-php-v8.0
98113
```

core/php8.1Action/CHANGELOG.md

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

core/php8.1Action/Dockerfile

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

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

core/php8.1Action/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.1Action/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.1"
5+
}
6+
},
7+
"require": {
8+
"guzzlehttp/guzzle": "7.4.5",
9+
"ramsey/uuid": "4.4.0"
10+
}
11+
}

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