From c6c3422f3e4afc48bcf350cb55085bc1ed056f7a Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 19 Sep 2021 09:58:32 -0700 Subject: [PATCH 1/5] Add recipe for runtime/bref --- runtime/bref/0.2/bootstrap | 18 +++++++++++ runtime/bref/0.2/manifest.json | 10 +++++++ runtime/bref/0.2/post-install.txt | 4 +++ runtime/bref/0.2/serverless.yaml | 50 +++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 runtime/bref/0.2/bootstrap create mode 100644 runtime/bref/0.2/manifest.json create mode 100644 runtime/bref/0.2/post-install.txt create mode 100644 runtime/bref/0.2/serverless.yaml diff --git a/runtime/bref/0.2/bootstrap b/runtime/bref/0.2/bootstrap new file mode 100644 index 000000000..4fefeaa16 --- /dev/null +++ b/runtime/bref/0.2/bootstrap @@ -0,0 +1,18 @@ +#!/bin/sh + +# +# Keep this file in the application's root or install bref/extra-php-extensions. +# See https://github.com/php-runtime/bref +# + +# 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 \ No newline at end of file diff --git a/runtime/bref/0.2/manifest.json b/runtime/bref/0.2/manifest.json new file mode 100644 index 000000000..33e18b0ab --- /dev/null +++ b/runtime/bref/0.2/manifest.json @@ -0,0 +1,10 @@ +{ + "copy-from-recipe": { + "serverless.yaml": "serverless.yml", + "bootstrap": "bootstrap" + }, + "gitignore": [ + "/.serverless/" + ], + "aliases": [ "bref" ] +} diff --git a/runtime/bref/0.2/post-install.txt b/runtime/bref/0.2/post-install.txt new file mode 100644 index 000000000..ecd261c26 --- /dev/null +++ b/runtime/bref/0.2/post-install.txt @@ -0,0 +1,4 @@ + * Read the full documentation to properly configure your + Symfony application at https://bref.sh/docs/frameworks/symfony.html + + * Bref documentation: https://bref.sh/docs/ diff --git a/runtime/bref/0.2/serverless.yaml b/runtime/bref/0.2/serverless.yaml new file mode 100644 index 000000000..4c683c598 --- /dev/null +++ b/runtime/bref/0.2/serverless.yaml @@ -0,0 +1,50 @@ +# Read the documentation at https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/ +service: my-symfony-app +configValidationMode: error + +provider: + name: aws + # The AWS region in which to deploy (us-east-1 is the default) + region: us-east-1 + # The stage of the application, e.g. dev, production, staging… ('dev' is the default) + stage: dev + runtime: provided.al2 + environment: + # Symfony environment variables + APP_ENV: prod + APP_RUNTIME: Runtime\Bref\Runtime + BREF_LOOP_MAX: 1 # Increase to keep the Lambda process alive between requests + +plugins: + - ./vendor/bref/bref + +functions: + # This function runs the Symfony website/API + web: + handler: public/index.php + timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds) + layers: + - ${bref:layer.php-80} + events: + - httpApi: '*' + + # This function let us run console commands in Lambda + console: + handler: bin/console + timeout: 120 # in seconds + layers: + - ${bref:layer.php-80} + +package: + patterns: + # Excluded files and folders for deployment + - '!assets/**' + - '!node_modules/**' + - '!public/build/**' + - '!tests/**' + - '!var/**' + # If you want to include files and folders that are part of excluded folders, + # add them at the end + - 'var/cache/prod/**' + - 'public/build/entrypoints.json' + - 'public/build/manifest.json' From 180dceaef98b1dbc5b4866aca6bd212bdefdcb14 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 19 Sep 2021 11:01:49 -0700 Subject: [PATCH 2/5] Added fixes --- runtime/bref/0.2/serverless.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/bref/0.2/serverless.yaml b/runtime/bref/0.2/serverless.yaml index 4c683c598..25c762227 100644 --- a/runtime/bref/0.2/serverless.yaml +++ b/runtime/bref/0.2/serverless.yaml @@ -7,13 +7,14 @@ provider: # The AWS region in which to deploy (us-east-1 is the default) region: us-east-1 # The stage of the application, e.g. dev, production, staging… ('dev' is the default) - stage: dev + stage: prod runtime: provided.al2 environment: # Symfony environment variables APP_ENV: prod APP_RUNTIME: Runtime\Bref\Runtime BREF_LOOP_MAX: 1 # Increase to keep the Lambda process alive between requests + # SYMFONY_DECRYPTION_SECRET: ${ssm:/stripe-notifications/prod-decrypt-private-key} plugins: - ./vendor/bref/bref @@ -48,3 +49,4 @@ package: - 'var/cache/prod/**' - 'public/build/entrypoints.json' - 'public/build/manifest.json' + - '.env*' From 4e522cd65c39a9ee13a02297eb63c1bf516ad98a Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Sun, 19 Sep 2021 22:54:16 -0700 Subject: [PATCH 3/5] Update runtime/bref/0.2/serverless.yaml Co-authored-by: Fabien Potencier --- runtime/bref/0.2/serverless.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/bref/0.2/serverless.yaml b/runtime/bref/0.2/serverless.yaml index 25c762227..9fa797d93 100644 --- a/runtime/bref/0.2/serverless.yaml +++ b/runtime/bref/0.2/serverless.yaml @@ -14,7 +14,7 @@ provider: APP_ENV: prod APP_RUNTIME: Runtime\Bref\Runtime BREF_LOOP_MAX: 1 # Increase to keep the Lambda process alive between requests - # SYMFONY_DECRYPTION_SECRET: ${ssm:/stripe-notifications/prod-decrypt-private-key} + # SYMFONY_DECRYPTION_SECRET: ${ssm:/my-symfony-app/prod-decrypt-private-key} plugins: - ./vendor/bref/bref From 49c99dc7d446b9afc3411d536c9686a72ddd020e Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 19 Sep 2021 23:07:20 -0700 Subject: [PATCH 4/5] Add EOL --- runtime/bref/0.2/bootstrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/bref/0.2/bootstrap b/runtime/bref/0.2/bootstrap index 4fefeaa16..54a3b9158 100644 --- a/runtime/bref/0.2/bootstrap +++ b/runtime/bref/0.2/bootstrap @@ -15,4 +15,4 @@ 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 \ No newline at end of file +done From 1d82723b7143a571d8ea924b5a062b5b9ee5a609 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 19 Sep 2021 23:21:45 -0700 Subject: [PATCH 5/5] Use useDotenv: true --- runtime/bref/0.2/serverless.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/bref/0.2/serverless.yaml b/runtime/bref/0.2/serverless.yaml index 9fa797d93..a875157b4 100644 --- a/runtime/bref/0.2/serverless.yaml +++ b/runtime/bref/0.2/serverless.yaml @@ -1,6 +1,7 @@ # Read the documentation at https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/ service: my-symfony-app configValidationMode: error +useDotenv: true provider: name: aws @@ -49,4 +50,3 @@ package: - 'var/cache/prod/**' - 'public/build/entrypoints.json' - 'public/build/manifest.json' - - '.env*'