From 2641da22255b896c333dad1570005d26a5a39def Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Thu, 16 Mar 2023 12:39:48 +0100 Subject: [PATCH 1/4] Improve the default `serverless.yml` config --- stubs/serverless.yml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/stubs/serverless.yml b/stubs/serverless.yml index 3d96dcc..552523c 100644 --- a/stubs/serverless.yml +++ b/stubs/serverless.yml @@ -4,12 +4,12 @@ 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 variables + environment: + APP_ENV: production package: - # Directories to exclude from deployment + # Files and directories to exclude from deployment patterns: - '!node_modules/**' - '!public/storage' @@ -22,23 +22,20 @@ functions: # This function runs the Laravel website/API web: handler: public/index.php + runtime: php-81-fpm timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds) - layers: - - ${bref:layer.php-81-fpm} events: - httpApi: '*' # This function lets us run artisan commands in Lambda artisan: handler: artisan + runtime: php-81-console timeout: 720 # in seconds - layers: - - ${bref:layer.php-80} # PHP - - ${bref:layer.console} # The "console" layer events: - # We also schedule this function to run the scheduler every minute + # We also schedule this function to run the scheduler every 5 minutes - schedule: - rate: rate(1 minute) + rate: rate(5 minutes) input: '"schedule:run"' plugins: From dde6baf33408c559ba40a71663c895b1cabfc912 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Mon, 20 Mar 2023 14:23:57 +0100 Subject: [PATCH 2/4] Set the scheduler for every minute, but commented by default See https://github.com/brefphp/laravel-bridge/pull/100#discussion_r1138961907 --- stubs/serverless.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stubs/serverless.yml b/stubs/serverless.yml index 552523c..dc337cc 100644 --- a/stubs/serverless.yml +++ b/stubs/serverless.yml @@ -32,11 +32,11 @@ functions: handler: artisan runtime: php-81-console timeout: 720 # in seconds - events: - # We also schedule this function to run the scheduler every 5 minutes - - schedule: - rate: rate(5 minutes) - input: '"schedule:run"' + # Uncomment to also schedule this function to run the scheduler every minute + #events: + # - schedule: + # rate: rate(1 minute) + # input: '"schedule:run"' plugins: # We need to include the Bref plugin From 52fe01cd34400c5d08de22aeddd03a76e2a8ddb6 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Mon, 20 Mar 2023 14:26:58 +0100 Subject: [PATCH 3/4] Dynamic environment in comment See https://github.com/brefphp/laravel-bridge/pull/100#discussion_r1138965765 --- stubs/serverless.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/serverless.yml b/stubs/serverless.yml index dc337cc..367197f 100644 --- a/stubs/serverless.yml +++ b/stubs/serverless.yml @@ -6,7 +6,7 @@ provider: region: us-east-1 # Environment variables environment: - APP_ENV: production + APP_ENV: production # Or use ${sls:stage} if you want the environment to match the stage package: # Files and directories to exclude from deployment From 73105a44199255b3367a2286bbb878420f9ffd06 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Mon, 20 Mar 2023 14:28:26 +0100 Subject: [PATCH 4/4] Simplify comment --- stubs/serverless.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/serverless.yml b/stubs/serverless.yml index 367197f..ce2fc0a 100644 --- a/stubs/serverless.yml +++ b/stubs/serverless.yml @@ -32,7 +32,7 @@ functions: handler: artisan runtime: php-81-console timeout: 720 # in seconds - # Uncomment to also schedule this function to run the scheduler every minute + # Uncomment to also run the scheduler every minute #events: # - schedule: # rate: rate(1 minute)