Skip to content

Commit

Permalink
Add PHP 7.1 as a kind (apache#2415)
Browse files Browse the repository at this point in the history
* Implement PHP 7.1 kind
* Add tests for PHP 7.1 action
* Add PHP action documentation

Build the Docker container from php:7.1-alpine and implement the HTTP
server using PHP's built in server.

Note that when using a zip file, the router requires that the `main`
function is stored in `index.php`.

Note about the runner:
The runner sets the exit code to 1 if it has set the last line of stdout
to a string suitable for presentation to the user. Therefore, if the
exit code is not one, then display a generic message.

If there's a runtime error in the action (i.e. not spotted by linter),
then looking for the main() function will find it. Render the error to
the logs so that the user knows what's happened.

Note about vendor folder in a PHP zip:
If the PHP vendor file has a vendor directory, then this directory needs
to be used rather than the one supplied in the action container.

To do this, we require src/vendor/autoload.php which will exist if the
zip file contains it. For the two cases where (1) zip file does not contain a
vendor folder, or (2) when running a non-binary code action, we move the
container's vendor folder into src/.
  • Loading branch information
akrabat authored and rabbah committed Jul 24, 2017
1 parent 0f7cc54 commit 9ef48f7
Show file tree
Hide file tree
Showing 12 changed files with 1,068 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ansible/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ runtimesManifest:
attachmentType: "application/java-archive"
sentinelledLogs: false
requireMain: true
php:
- kind: "php:7.1"
default: true
deprecated: false
image:
name: "action-php-v7.1"
blackboxes:
- name: "dockerskeleton"

Expand Down
50 changes: 50 additions & 0 deletions core/php7.1Action/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM php:7.1-alpine

RUN \

apk update && apk upgrade && \

# install dependencies
apk add \
postgresql-dev \
icu \
icu-libs \
icu-dev \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libxml2-dev \

&& \

# install useful PHP extensions
docker-php-ext-install \
opcache \
mysqli \
pdo_mysql \
pdo_pgsql \
intl \
bcmath \
zip \
gd \
soap \

&& \

# install Composer
cd /tmp && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

# create src directory to store action files
RUN mkdir -p /action/src

# install Composer dependencies
COPY composer.json /action
RUN cd /action && /usr/bin/composer install --no-plugins --no-scripts --prefer-dist --no-dev -o && rm composer.lock

# copy required files
COPY router.php /action
COPY runner.php /action

# Run webserver on port 8080
EXPOSE 8080
CMD [ "php", "-S", "0.0.0.0:8080", "-d", "expose_php=0", "-d", "html_errors=0", "-d", "error_reporting=E_ALL", "/action/router.php" ]
2 changes: 2 additions & 0 deletions core/php7.1Action/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ext.dockerImageName = 'action-php-v7.1'
apply from: '../../gradle/docker.gradle'
11 changes: 11 additions & 0 deletions core/php7.1Action/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"config": {
"platform": {
"php": "7.1"
}
},
"require": {
"guzzlehttp/guzzle": "^6.3",
"ramsey/uuid": "^3.6"
}
}
Loading

0 comments on commit 9ef48f7

Please sign in to comment.