Deploy Laravel Vapor Project with Docker Tutorial

By Hardik Savani July 13, 2021 Category : Laravel

This tutorial will provide example of deploy laravel vapor with docker. step by step explain laravel vapor docker image. We will look at example of how to deploy laravel vapor project with docker. This article goes in detailed on docker laravel project.

When you have more composer packages and exceeds the maximum size allowed by AWS Lambda, then you must have to use docker image for deploy laravel vapor project. laravel provide runtime docker based deployment. so you can follow bellow step and easily done deploy with laravel vapor project.

Yesterday i was working on my laravel app and i installed 3 new composer packages, then i just deploy it i got error "Your application exceeds the maximum size allowed by AWS Lambda" as bellow screenshot. i used runtime php8, but now i need to change that. so i used docker base deployment. just follow bellow step to make it done.

Install Docker

first you need to install docker in your system. you can follow bellow link to install docker in your OS.

If you are using ubuntu then follow bellow step here:

sudo apt-get update

sudo apt-get install \

apt-transport-https \

ca-certificates \

curl \

gnupg \


curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \

"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \

$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli

apt-cache madison docker-ce

Configure vapor.yml File

after installed docker successfully. you need to configure your docker file and vapor.yml file as bellow:

There will be two files for docker configuration, one for staging and another for production as bellow:


FROM laravelphp/vapor:php80

COPY . /var/task


FROM laravelphp/vapor:php80

COPY . /var/task

Set runtime option "docker" as bellow file.


id: 22442

name: itsolutionstuff-vapor



memory: 1024

cli-memory: 512

runtime: docker


- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev'


memory: 1024

cli-memory: 512

runtime: docker

database: itsolutionstuff-vapor-staging

storage: itsolutionstuff-s3-files


- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install'

now just deploy it.

php vendor/bin/vapor deploy

i will works. i hope it can help you...

Tags :