One of the limitations of AWS Lambda is that the deployment size, including layers, must not exceed 250 MB. This is not ideal for large projects that have many composer dependencies. In addition, many people interested in Laravel Vapor would like to install additional PHP extensions that are not included in the native Vapor runtimes.
Earlier this month, AWS announced Container Image Support for Lambda functions. This allows developers to package and deploy Lambda functions as Docker container images of up to 10GB.
Just weeks later, we're excited to introduce Docker based deployment support for Laravel Vapor. To get started, make sure you are running the latest versions of laravel/vapor-core
and laravel/vapor-cli
and then create a fresh Vapor environment:
vapor env my-environment --docker
The --docker
option will instruct Vapor to create a my-environment.Dockerfile
file and set the runtime
configuration option within this file to docker
. By default, the my-environment.Dockerfile
will look like the following:
FROM laravelphp/vapor:php74
COPY . /var/task
If you have an existing environment that you would like to switch to docker based deployments, you'll need to update the runtime
configuration in your vapor.yml
file and set it to docker
. After that, you need to create a .Dockerfile
for the environment.
Vapor offers several base images that are based on Alpine Linux - these images have many of the common libraries and PHP extensions installed by default.
You can install additional PHP extensions or libraries by updating the environment's corresponding Dockerfile. For example, here's how you may install the FFmpeg library and the XML-RPC PHP extension:
FROM laravelphp/vapor:php74
RUN apk --update add ffmpeg
RUN docker-php-ext-install xmlrpc
COPY . /var/task
Once you are ready to deploy, run the vapor deploy my-environment
command and Vapor will build and publish the Docker image. In addition, Vapor will configure the underlying AWS Lambda function to use the image as its runtime. Of course, you should ensure that you have installed Docker on your local machine.
With the introduction of Docker based deployments, you can now deploy larger applications to Laravel Vapor and easily install any extra libraries or PHP extensions that your projects may need.
If you haven't tried Laravel Vapor, now is a great time to start deploying your application with infinite scale! You can create your account today at: https://vapor.laravel.com