diff --git a/stubs/serverless.yml b/stubs/serverless.yml index 3d96dcc..f4d0afe 100644 --- a/stubs/serverless.yml +++ b/stubs/serverless.yml @@ -1,46 +1,110 @@ +# This config skeleton deploys a solid foundation for your Serverless Laravel applications +# - TODO: Ensure you have the serverless-lift plugin installed: serverless plugin install -n serverless-lift +# - TODO: Add your Domain(s) and SSLs within ACM used for Cloudfront - NOTE: THIS **MUST** BE WITHIN THE us-east-1 REGION + service: laravel -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 +params: + default: + domain: dev.example.com # TODO: Add your staging/dev domain/subdomain here + amazon_ssl_arn: arn:aws:acm:us-east-1:xxxxxxxxx:certificate/xxxx-xxxx-xxxx # TODO: Issue and verify SSL - Must be created within *us-east-1* here: https://us-east-1.console.aws.amazon.com/acm/home?region=us-east-1#/certificates/request/public + log_retention_days: 5 + laravel_env: local + laravel_debug: true + tags: # Tag all of our resources - Useful for cost analysis using + project_name: ${self:service} + stage: ${opt:stage, self:provider.stage} + prod: + domain: prod.example.com # TODO: Add your prod domain here + amazon_ssl_arn: arn:aws:acm:us-east-1:xxxxxxxxx:certificate/xxxx-xxxx-xxxx # TODO: Issue and verify SSL - Must be created within *us-east-1* here: https://us-east-1.console.aws.amazon.com/acm/home?region=us-east-1#/certificates/request/public + log_retention_days: 30 + laravel_env: production + laravel_debug: false -package: - # Directories to exclude from deployment - patterns: - - '!node_modules/**' - - '!public/storage' - - '!resources/assets/**' - - '!storage/**' - - '!tests/**' +provider: + name: aws + region: us-east-1 # The AWS region in which to deploy (us-east-1 is the default) + stage: dev + logRetentionInDays: ${param:log_retention_days} + stackTags: ${param:tags} + tags: ${param:tags} + environment: # Add any environment variables for your Lambda environment here + APP_URL: https://${param:domain} + APP_ENV: ${param:laravel_env} + APP_DEBUG: ${param:laravel_debug} + MAINTENANCE_MODE: ${param:maintenance, null} + QUEUE_CONNECTION: sqs + SQS_QUEUE: ${construct:laravel-default-queue.queueUrl} functions: + # This function runs the Laravel website/API using PHP-FPM + # If you wish to use Laravel Octane, please comment this function, and replace with the commented one below: + web: + handler: public/index.php + runtime: php-82-fpm + timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds) + events: + - httpApi: '*' + + # This function runs the Laravel website/API using Laravel Octane + # If you wish to use Laravel without Octane, please comment this function, and replace with the one above: + #web: + # handler: Bref\LaravelBridge\Http\OctaneHandler + # environment: + # BREF_LOOP_MAX: 250 + # OCTANE_PERSIST_DATABASE_SESSIONS: 1 + # runtime: php-82 + # timeout: 30 # in seconds + # events: + # - httpApi: '*' - # This function runs the Laravel website/API - web: - handler: public/index.php - 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 - 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 - - schedule: - rate: rate(1 minute) - input: '"schedule:run"' + # This function lets us run Artisan commands within the Lambda environment + # To use: instead of `php artisan db:seed` you'd run from your local env to seed your Lambda environment: + # serverless bref:cli --args="db:seed" + artisan: + handler: artisan + runtime: php-82-console + timeout: 720 # in seconds + events: + - schedule: # We also schedule this function to run the scheduler every 5 minutes + rate: rate(5 minutes) + input: '"schedule:run"' + +constructs: + laravel-default-queue: + type: queue + maxRetries: 1 + worker: + handler: Bref\LaravelBridge\Queue\QueueHandler + timeout: 59 + runtime: php-82 + + website: + type: server-side-website + domain: ${param:domain} + certificate: ${param:amazon_ssl_arn} + assets: + '/vendor/*': public/vendor + '/build/assets/*.css': public/build/assets + '/build/assets/*.js': public/build/assets + '/images/*': public/images + '/favicon.ico': public/favicon.ico + '/robots.txt': public/robots.txt + +custom: + scriptable: + hooks: + after:deploy:deploy: + - serverless bref:cli --stage=${sls:stage} --args="migrate --force" # Run any new migrations on deployment plugins: - # We need to include the Bref plugin - - ./vendor/bref/bref + - ./vendor/bref/bref # We need to include the Bref plugin + - serverless-lift + +package: + patterns: # Files and directories to exclude from deployment + - '!node_modules/**' + - '!public/storage' + - '!resources/assets/**' + - '!storage/**' + - '!tests/**'