Skip to content

Commit a5624ab

Browse files
authored
PHP 8.2 Initial commit (#134)
* PHP 8.2 Initial commit * Package updates
1 parent aebeab4 commit a5624ab

11 files changed

Lines changed: 445 additions & 4 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ jobs:
9292
./gradlew :core:php8.0Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT
9393
./gradlew :core:php8.1Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=nightly
9494
./gradlew :core:php8.1Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT
95+
./gradlew :core:php8.2Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=nightly
96+
./gradlew :core:php8.2Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT
9597
- name: Push Release Images
9698
if: ${{ env.PUSH_RELEASE == 'true' }}
9799
working-directory: runtime

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,16 @@
2323

2424
## PHP versions
2525

26-
This runtime provides PHP 8.1, 8.0
26+
This runtime provides PHP 8.2, 8.1 and 8.0
2727

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

31+
PHP 8.2:
32+
```
33+
wsk action update myAction myAction.php --docker openwhisk/action-php-v8.2:latest
34+
```
35+
3136
PHP 8.1:
3237
```
3338
wsk action update myAction myAction.php --docker openwhisk/action-php-v8.1:latest
@@ -43,6 +48,11 @@ This works on any deployment of Apache OpenWhisk
4348
### To use on deployment that contains the runtime as a kind
4449
To use as a kind action
4550

51+
PHP 8.2:
52+
```
53+
wsk action update myAction myAction.php --kind php:8.2
54+
```
55+
4656
PHP 8.1:
4757
```
4858
wsk action update myAction myAction.php --kind php:8.1
@@ -57,19 +67,21 @@ wsk action update myAction myAction.php --kind php:8.0
5767
### Local development
5868

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

6576
Build and Push image
6677
```
6778
docker login
79+
./gradlew core:php8.2Action:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io
80+
./gradlew core:php8.1Action:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io
6881
./gradlew core:php8.0Action:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io
69-
./gradlew core:php7.4Action:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io
7082
```
7183

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

7587
Set `ROOTDIR` to the root directory of this repository.
@@ -91,8 +103,13 @@ ln -s ${ROOTDIR}/ansible/environments/local ${OPENWHISK_HOME}/ansible/environmen
91103
wskdev fresh -t local-php
92104
```
93105

106+
94107
To use as docker action push to your own dockerhub account
95108
```
109+
docker tag whisk/php8.2Action $user_prefix/action-php-v8.2
110+
docker push $user_prefix/action-php-v8.2
111+
```
112+
```
96113
docker tag whisk/php8.1Action $user_prefix/action-php-v8.1
97114
docker push $user_prefix/action-php-v8.1
98115
```

core/php8.2Action/CHANGELOG.md

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

core/php8.2Action/Dockerfile

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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.20 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.20 AS builder_release
29+
ARG GO_PROXY_RELEASE_VERSION=1.20@1.22.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.2-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+
# Upgrade installed packages to get latest security fixes if the base image does not contain them already.
44+
&& apt-get upgrade -y --no-install-recommends \
45+
&& apt-get -y install --no-install-recommends \
46+
unzip \
47+
libfreetype6 \
48+
libicu67 \
49+
libjpeg62-turbo \
50+
libpng16-16 \
51+
libssl1.1 \
52+
libxml2 \
53+
libzip4 \
54+
libpq5 \
55+
zip \
56+
libfreetype6-dev \
57+
libicu-dev \
58+
libjpeg-dev \
59+
libpng-dev \
60+
libssl-dev \
61+
libxml2-dev \
62+
libzip-dev \
63+
postgresql-server-dev-13 \
64+
\
65+
&& docker-php-ext-install \
66+
bcmath \
67+
gd \
68+
intl \
69+
mysqli \
70+
opcache \
71+
pdo_mysql \
72+
pdo_pgsql \
73+
soap \
74+
zip \
75+
\
76+
&& mkdir -p /usr/src/php/ext/mongodb \
77+
&& curl -fsSL https://pecl.php.net/get/mongodb-1.14.0 | tar xvz -C "/usr/src/php/ext/mongodb" --strip 1 \
78+
&& docker-php-ext-install -j$(nproc) mongodb \
79+
\
80+
&& apt-get purge -y --auto-remove $PHPIZE_DEPS \
81+
&& apt-get purge -y --auto-remove libfreetype6-dev \
82+
libicu-dev \
83+
libjpeg-dev \
84+
libpng-dev \
85+
libssl-dev \
86+
libxml2-dev \
87+
libzip-dev \
88+
postgresql-server-dev-13 \
89+
&& apt-get autoremove -y \
90+
&& apt-get clean -y \
91+
&& rm -rf /usr/src/php
92+
93+
COPY php.ini /usr/local/etc/php
94+
95+
# install composer
96+
RUN curl -s -f -L -o /tmp/installer.php https://getcomposer.org/installer \
97+
&& php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer \
98+
&& composer --ansi --version --no-interaction --no-plugins --no-scripts
99+
100+
# install default Composer dependencies
101+
RUN mkdir -p /phpAction/composer
102+
COPY composer.json /phpAction/composer
103+
RUN cd /phpAction/composer && /usr/bin/composer install --no-plugins --no-scripts --prefer-dist --no-dev -o && rm composer.lock
104+
105+
# install proxy binary along with compile and launcher scripts
106+
RUN mkdir -p /phpAction/action
107+
WORKDIR /phpAction
108+
COPY --from=builder_source /bin/proxy /bin/proxy_source
109+
COPY --from=builder_release /bin/proxy /bin/proxy_release
110+
RUN mv /bin/proxy_${GO_PROXY_BUILD_FROM} /bin/proxy
111+
ADD compile.php /bin/compile.php
112+
ADD runner.php /bin/runner.php
113+
ENV OW_COMPILER=/bin/compile.php
114+
115+
ENTRYPOINT [ "/bin/proxy" ]

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

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

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