/laravel-lambda-docker-bref

Demo Laravel application on AWS Lambda function with Docker container image using Bref

Primary LanguagePHP

Delpoy Laravel on AWS Lambda with Docker using Bref

Step 1. Create your project

curl -s https://laravel.build/larademo | bash

Step 2. install requirements and generate serverless.yml

cd larademo
./vendor/bin/sail up -d
./vendor/bin/sail composer require bref/bref bref/laravel-bridge
./vendor/bin/sail php artisan vendor:publish --tag=serverless-config
./vendor/bin/sail down

Step 3. Create Dockerfile and modify serverless.yml

FROM bref/php-80-fpm
COPY . /var/task
CMD [ "public/index.php" ]
service: laravel

provider:
    name: aws
    # The AWS region in which to deploy (us-east-1 is the default)
    region: {opt:region, us-east-1}
    # The stage of the application, e.g. dev, production, staging… ('dev' is the default)
    stage: dev
    runtime: provided.al2

    ecr:
        images:
            laravel:
                path: ./
package:
    # Directories to exclude from deployment
    exclude:
        - node_modules/**
        - public/storage
        - resources/assets/**
        - storage/**
        - tests/**

functions:
    # This function runs the Laravel website/API
    web:
        image:
            name: laravel
        events:
            -   httpApi: '*'

Step 4. Deploy!

sls deploy --region ap-northeast-1 # use your region

References