PHP Classes

Laravel Docker Kubernetes: Run a Laravel project using Docker and Kubernetes

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 31 All time: 11,135 This week: 455Up
Version License PHP version Categories
laravel-docker-k8s 1.0.0The PHP License5PHP 5, Libraries, Project Management
Description 

Author

This package can run a Laravel project using Docker and Kubernetes.

It provides an example project based on Laravel that that is ready to be deployed.

The package also provides configuration files to deploy the project using Docker and Kubernetes.

Innovation Award
PHP Programming Innovation award nominee
March 2022
Number 8
Docker is a tool used in projects that need to deploy applications that may need to use multiple servers to run in a scalable way. Docker can deploy applications as containers.

Kubernetes is a system that can orchestrate the deployment of applications using multiple containers.

This package demonstrates how you can deploy a Laravel project combining the possibilities made available by Docker and Kubernetes.

Manuel Lemos
Picture of Nahidul Hasan
  Performance   Level  
Innovation award
Innovation award
Nominee: 7x

 

Documentation

Laravel-docker-kubernetes

From here you will be able to know that how you will run your Laravel project using Docker and how you will deploy using Kubernetes(minikube)

Run the project using docker

Clone the project
 

Now run the following command from your terminal one by one. Running the commands be sure that you have installed docker.You will get install instructions from this link

docker-compose build

docker-compose up -d

Now browse project

 http://localhost:8083/

Deploy the project using Kubernetes

At first build image running the command:

docker build . -f ./deploy/dockerfile -t laravel:v4

Now login in docker hub. Running the command be sure that you have created an account in docker hub. If not go to the link and create account.

 docker login
 

Now run the following command for Pushing image in docker registry.In the command nahid35 is my docker id and laravel is repository name and v4 is tag name. Modify command according to your docker id, repository name and tag name.

docker tag laravel:v4 docker.io/nahid35/laravel:v4

docker push docker.io/nahid35/laravel:v4

Now run minikube. Running the commands be sure that you have installed minikube. If not installed, you can get install instructions from this link

minikube start

Now run the following commands for deploying your project:


kubectl apply -f deploy/app/secret.yml

kubectl apply -f deploy/app/deploy.yml

kubectl apply -f deploy/app/service.yml


Now run the following commands to see minikube dashboard:

minikube dashboard

You will get this url :

http://192.168.99.100:30000/#!/overview?namespace=default

kubectl get svc

Running above command you will get following information:

NAME | TYPE | CLUSTER-IP | EXTERNAL-IP | PORT(S) | AGE ---------|---------------|-----------------|----------------|------------|---------- kubernetes | ClusterIP | 10.0.0.1 | <none> | 443/TCP | 27d laravel-api | LoadBalancer | 10.0.0.11 | <pending> | 80:32676/TCP | 4m

Now you can browse your project using following url :

 http://192.168.99.100:32676/

Extra Note :

> - If you want to use different database or different port etc, You have to change in the docker-compose.yml file.

> - If you modify .env file, You have to run following command:

     base64 -b -i deploy/env/.env

> - Running the command you will get base 64 encoded string. Put the string in deploy\app\secret.yml. And then run the commands for deploying.


  Files folder image Files (105)  
File Role Description
Files folder imageapp (1 file, 4 directories)
Files folder imagebootstrap (2 files)
Files folder imageconfig (11 files)
Files folder imagedatabase (3 directories)
Files folder imagedeploy (5 files, 3 directories)
Files folder imagedocker (2 directories)
Files folder imagepublic (4 files, 2 directories)
Files folder imageresources (3 directories)
Files folder imageroutes (4 files)
Files folder imagetests (2 files, 2 directories)
Accessible without login Plain text file .dockerignore Data Auxiliary data
Accessible without login Plain text file .env.example Data Auxiliary data
Plain text file artisan Class Class source
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file docker-compose.yml Data Auxiliary data
Accessible without login Plain text file Dockerfile Data Auxiliary data
Accessible without login Plain text file entrypoint Data Auxiliary data
Accessible without login Plain text file local-volumes.yaml Data Auxiliary data
Accessible without login Plain text file mysql-deployment.yaml Data Auxiliary data
Accessible without login Plain text file package.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file push.sh Data Auxiliary data
Accessible without login Plain text file readme.md Doc. Documentation
Accessible without login Plain text file server.php Aux. Auxiliary script
Accessible without login Plain text file webpack.mix.js Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:31
This week:0
All time:11,135
This week:455Up