Deploy Laravel Vapor Project with Docker Tutorial
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
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Image Upload in Laravel Vapor?
- Laravel Vapor cli installation error for require league/flysystem-aws-s3-v3
- How to Setup Database in Laravel Vapor?
- How to Deploy Project with Laravel Vapor?
- Laravel Http Curl Get Request Example
- Laravel Sweet Alert Confirm Delete Example
- How to Get Current User Location in Laravel?
- Laravel Eloquent Group By Year with Sum Example
- Laravel 8 Queue Step by Step Tutorial Example
- Laravel 8 Import Export Excel and CSV File Tutorial
- Laravel Deployment on Cloudways with Envoyer