Skip to content
/ laravel-docker Public template

A generic docker environment for Laravel local development

License

Notifications You must be signed in to change notification settings

rakibdevs/laravel-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Docker 🐳

A generic docker environment for Laravel with mySql and Nginx

Insstallation

  1. Click Use this template
  2. Clone the repository containing the docker-compose.yml file.
  3. Run the following command to build the Docker image:
$ docker compose build

This command will download all the necessary dependencies and build the Docker image according to the specifications in the Dockerfile.

  1. Once the build is complete, run the following command to start the Docker container:
$ docker-compose up -d
  1. Run the following command to create a new Laravel project inside a src directory:
$ sudo chmod 777 src/
$ docker compose exec php composer create-project --prefer-dist laravel/laravel .

This command will install all the necessary dependencies and create a new Laravel project inside the src directory.

  1. Run other esential commands -
$ docker compose exec php php artisan storage:link
$ docker compose exec php chmod -R 777 storage bootstrap/cache
  1. Run the following command to migrate database docker compose exec php php artisan migrate:refresh. Before migration please update environment variable for database.
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=1234

Acces Webpage

To access the web page for your Laravel project, please follow these steps:

Ensure that the Docker container is running by running the command docker ps in your terminal or command prompt. This command will display a list of all the running Docker containers on your system.

Open a web browser and navigate to the following URL: http://localhost:8999. This URL corresponds to the port that has been exposed in the docker-compose.yml file for the Nginx service.

How to setup different PHP version?

To update the PHP version for your Docker container, please follow these steps:

Open the Dockerfile for your PHP image, which is located in the docker/php/ directory.

Update the FROM statement to use the base image for the PHP version you want to use. For example, to use PHP version 7.4, you can change the FROM statement to the following:

FROM php:7.4-fpm

Save the Dockerfile and build the Docker image again using the docker-compose build command.

Once the build is complete, start the Docker container using the docker-compose up command.

About

A generic docker environment for Laravel local development

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published