ItSolutionStuff.com

Deploy Laravel Vapor Project with Docker Tutorial

By Hardik Savani • November 5, 2023
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.

https://docs.docker.com/engine/install/

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 \

lsb-release

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \

"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \

$(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 containerd.io

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:

production.Dockerfile

FROM laravelphp/vapor:php80

COPY . /var/task

staging.Dockerfile

FROM laravelphp/vapor:php80

COPY . /var/task

Set runtime option "docker" as bellow file.

vapor.yml

id: 22442

name: itsolutionstuff-vapor

environments:

production:

memory: 1024

cli-memory: 512

runtime: docker

build:

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

staging:

memory: 1024

cli-memory: 512

runtime: docker

database: itsolutionstuff-vapor-staging

storage: itsolutionstuff-s3-files

build:

- '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...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Image Upload in Laravel Vapor?

Read Now →

Laravel Vapor cli installation error for require league/flysystem-aws-s3-v3

Read Now →

How to Setup Database in Laravel Vapor?

Read Now →

How to Deploy Project with Laravel Vapor?

Read Now →

Laravel Http Curl Get Request Example

Read Now →

Laravel Sweet Alert Confirm Delete Example

Read Now →

How to Get Current User Location in Laravel?

Read Now →

Laravel Eloquent Group By Year with Sum Example

Read Now →

Laravel 8 Queue Step by Step Tutorial Example

Read Now →

Laravel 8 Import Export Excel and CSV File Tutorial

Read Now →

Laravel Deployment on Cloudways with Envoyer

Read Now →