-
-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add recipe for runtime/bref #1001
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"copy-from-recipe": { | ||
"serverless.yaml": "serverless.yml", | ||
"bootstrap": "bootstrap" | ||
}, | ||
"gitignore": [ | ||
"/.serverless/" | ||
], | ||
"aliases": [ "bref" ] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* <fg=blue>Read</> the full documentation to properly configure your | ||
Symfony application at <comment>https://bref.sh/docs/frameworks/symfony.html</> | ||
|
||
* Bref documentation: <comment>https://bref.sh/docs/</> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,52 @@ | ||||||||||||||||||||||
# 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 | ||||||||||||||||||||||
# 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: prod | ||||||||||||||||||||||
runtime: provided.al2 | ||||||||||||||||||||||
environment: | ||||||||||||||||||||||
# Symfony environment variables | ||||||||||||||||||||||
APP_ENV: prod | ||||||||||||||||||||||
Comment on lines
+11
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
By doing this, the user can easily deploy a prod/env Symfony app by specifying At work, we used to work on multiples stages/Symfony environments:
What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed if you use the variable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 this is not needed, you should consider Also you might not want to mix Symfony env and stages, as you can have many stages (e.g. one per developer) which would not map to Symfony environments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely agree here, those are two different concepts that I would not mix to avoid confusion. Also see my previous comment here about this #1001 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, didn't know about that, thanks! |
||||||||||||||||||||||
APP_RUNTIME: Runtime\Bref\Runtime | ||||||||||||||||||||||
BREF_LOOP_MAX: 1 # Increase to keep the Lambda process alive between requests | ||||||||||||||||||||||
Nyholm marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
# SYMFONY_DECRYPTION_SECRET: ${ssm:/my-symfony-app/prod-decrypt-private-key} | ||||||||||||||||||||||
|
||||||||||||||||||||||
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/**' | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should exclude the whole There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These assets should be served through s3 or Cloudfront. Serving them from lambda is highly inefficient in terms of performance or costs. See https://bref.sh/docs/frameworks/symfony.html#assets and https://bref.sh/docs/websites.html There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh good point, thx! |
||||||||||||||||||||||
- '!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' | ||||||||||||||||||||||
Nyholm marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm missing something you may not want to use
useDotenv: true
.This will inject all
.env
env variables (application variables) into theserverless
process (build/deploy process). And it will also automatically exclude.env
files from being uploaded.This feature was supposed to be enabled by default in Serverless Framework v3, but we've decided to keep it opt-in to avoid messing up applications. At the moment the error message says that this line should be added, but this will be changed soon.
If you want to control
.env
files separately fromserverless deploy
then you don't want to mix the 2.