From 5fbcc972e63697a132819812b3969cfdd93dbd18 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 20 Mar 2021 15:06:15 +0100 Subject: [PATCH] Adding Layer to support Symfony Runtime component --- Makefile | 8 ++++---- runtime/Makefile | 7 ++++++- runtime/layers/layer-list.php | 4 ++++ runtime/layers/publish.php | 4 ++++ runtime/layers/sf-runtime/Dockerfile | 7 +++++++ runtime/layers/sf-runtime/bootstrap | 13 +++++++++++++ runtime/layers/tests.php | 4 ++++ 7 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 runtime/layers/sf-runtime/Dockerfile create mode 100755 runtime/layers/sf-runtime/bootstrap diff --git a/Makefile b/Makefile index 199cdb3ea..ff170d525 100644 --- a/Makefile +++ b/Makefile @@ -21,10 +21,10 @@ publish-docker-images: docker-images test $(DOCKER_TAG) for image in \ - "bref/php-73" "bref/php-73-fpm" "bref/php-73-console" "bref/php-73-fpm-dev" \ - "bref/php-74" "bref/php-74-fpm" "bref/php-74-console" "bref/php-74-fpm-dev" \ - "bref/php-80" "bref/php-80-fpm" "bref/php-80-console" "bref/php-80-fpm-dev" \ - "bref/php-81" "bref/php-81-fpm" "bref/php-81-console" "bref/php-81-fpm-dev" \ + "bref/php-73" "bref/php-73-runtime" "bref/php-73-fpm" "bref/php-73-console" "bref/php-73-fpm-dev" \ + "bref/php-74" "bref/php-74-runtime" "bref/php-74-fpm" "bref/php-74-console" "bref/php-74-fpm-dev" \ + "bref/php-80" "bref/php-80-runtime" "bref/php-80-fpm" "bref/php-80-console" "bref/php-80-fpm-dev" \ + "bref/php-81" "bref/php-81-runtime" "bref/php-81-fpm" "bref/php-81-console" "bref/php-81-fpm-dev" \ "bref/build-php-73" \ "bref/build-php-74" \ "bref/build-php-80" \ diff --git a/runtime/Makefile b/runtime/Makefile index 8aec43182..7caac882c 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -6,7 +6,7 @@ publish: layers cd layers ; php publish.php # Build the layers -layers: export/console.zip export/php-73.zip export/php-74.zip export/php-80.zip export/php-81.zip export/php-73-fpm.zip export/php-74-fpm.zip export/php-80-fpm.zip export/php-81-fpm.zip +layers: export/console.zip export/php-73.zip export/php-74.zip export/php-80.zip export/php-81.zip export/php-73-runtime.zip export/php-74-runtime.zip export/php-80-runtime.zip export/php-81-runtime.zip export/php-73-fpm.zip export/php-74-fpm.zip export/php-80-fpm.zip export/php-81-fpm.zip # The PHP runtimes export/php%.zip: docker-images @@ -58,6 +58,11 @@ docker-images: cd layers/console ; docker build -t bref/php-74-console --build-arg PHP_VERSION=74 . cd layers/console ; docker build -t bref/php-80-console --build-arg PHP_VERSION=80 . cd layers/console ; docker build -t bref/php-81-console --build-arg PHP_VERSION=81 . + # - sf-runtime + cd layers/sf-runtime ; docker build -t bref/php-73-runtime --build-arg PHP_VERSION=73 . + cd layers/sf-runtime ; docker build -t bref/php-74-runtime --build-arg PHP_VERSION=74 . + cd layers/sf-runtime ; docker build -t bref/php-80-runtime --build-arg PHP_VERSION=80 . + cd layers/sf-runtime ; docker build -t bref/php-81-runtime --build-arg PHP_VERSION=81 . # Other Docker images cd layers/fpm-dev ; docker build -t bref/php-73-fpm-dev --build-arg PHP_VERSION=73 . cd layers/fpm-dev ; docker build -t bref/php-74-fpm-dev --build-arg PHP_VERSION=74 . diff --git a/runtime/layers/layer-list.php b/runtime/layers/layer-list.php index 78a6f399a..2eb3ed5d4 100644 --- a/runtime/layers/layer-list.php +++ b/runtime/layers/layer-list.php @@ -14,12 +14,16 @@ const LAYER_NAMES = [ 'php-81', + 'php-81-runtime', 'php-81-fpm', 'php-80', + 'php-80-runtime', 'php-80-fpm', 'php-74', + 'php-74-runtime', 'php-74-fpm', 'php-73', + 'php-73-runtime', 'php-73-fpm', 'console', ]; diff --git a/runtime/layers/publish.php b/runtime/layers/publish.php index be91df05d..a8a15e367 100644 --- a/runtime/layers/publish.php +++ b/runtime/layers/publish.php @@ -10,12 +10,16 @@ $layers = [ 'php-81' => 'PHP 8.1 for event-driven PHP functions', + 'php-81-runtime' => 'PHP 8.1 for PHP applications using Symfony Runtime', 'php-81-fpm' => 'PHP-FPM 8.1 for web applications', 'php-80' => 'PHP 8.0 for event-driven PHP functions', + 'php-80-runtime' => 'PHP 8.0 for PHP applications using Symfony Runtime', 'php-80-fpm' => 'PHP-FPM 8.0 for web applications', 'php-74' => 'PHP 7.4 for event-driven PHP functions', + 'php-74-runtime' => 'PHP 7.4 for PHP applications using Symfony Runtime', 'php-74-fpm' => 'PHP-FPM 7.4 for web applications', 'php-73' => 'PHP 7.3 for event-driven PHP functions', + 'php-73-runtime' => 'PHP 7.3 for PHP applications using Symfony Runtime', 'php-73-fpm' => 'PHP-FPM 7.3 for web applications', 'console' => 'Console runtime for PHP applications', ]; diff --git a/runtime/layers/sf-runtime/Dockerfile b/runtime/layers/sf-runtime/Dockerfile new file mode 100644 index 000000000..26cea083c --- /dev/null +++ b/runtime/layers/sf-runtime/Dockerfile @@ -0,0 +1,7 @@ +ARG PHP_VERSION +FROM bref/php-$PHP_VERSION + +# Overwrite the original bootstrap +COPY bootstrap /opt/bootstrap +# Copy files to /var/runtime to support deploying as a Docker image +RUN cp /opt/bootstrap /var/runtime diff --git a/runtime/layers/sf-runtime/bootstrap b/runtime/layers/sf-runtime/bootstrap new file mode 100755 index 000000000..679188525 --- /dev/null +++ b/runtime/layers/sf-runtime/bootstrap @@ -0,0 +1,13 @@ +#!/bin/sh + +# Fail on error +set -e + +LAMBDA_ARGV=(${_HANDLER//:/ }) + +while true +do + # We redirect stderr to stdout so that everything + # written on the output ends up in Cloudwatch automatically + /opt/bin/php "${LAMBDA_ARGV[0]}" 2>&1 +done diff --git a/runtime/layers/tests.php b/runtime/layers/tests.php index 76d2e9957..cabb6a721 100644 --- a/runtime/layers/tests.php +++ b/runtime/layers/tests.php @@ -11,6 +11,10 @@ 'bref/php-74', 'bref/php-80', 'bref/php-81', + 'bref/php-73-runtime', + 'bref/php-74-runtime', + 'bref/php-80-runtime', + 'bref/php-81-runtime', 'bref/php-73-fpm', 'bref/php-74-fpm', 'bref/php-80-fpm',