Skip to content

papposilene/dockerized-laravel

Repository files navigation

dockerized-laravel

A pretty simplified Docker Compose workflow that sets up a LEMP network of containers for local Laravel development. You can view the full article that inspired this repo here.

Usage

To get started, make sure you have Docker installed on your system, and then clone this repository.

Next, navigate in your terminal to the directory you cloned this, and spin up the containers for the web server by running docker-compose build && docker-compose up -d.

After that completes, run docker-compose run --rm composer create-project --prefer-dist laravel/laravel . or clone a existent Laravel project in the root folder.

Bringing up the Docker Compose network with site instead of just using up, ensures that only our site's containers are brought up at the start, instead of all of the command containers as well. The following are built for our web server, with their exposed ports detailed:

  • nginx - :80
  • mysql - :3306
  • phpmyadmin - :8024
  • php - :9000
  • redis - :6379
  • mailhog - :8025

Three additional containers are included that handle Composer, NPM, and Artisan commands without having to have these platforms installed on your local computer. Use the following command examples from your project root, modifying them to fit your particular use case.

  • docker-compose run --rm composer update
  • docker-compose run --rm npm run dev
  • docker-compose run --rm artisan migrate or docker-compose run --rm artisan migrate:fresh --seed

phpMyAdmin

To access to your phpMyAdmin, go to http://localhost:8024/ and enter those credentials : server db, user homestead and password secret (or anything else you decide in the environnement variables in your docker-composer.yml file.

MailHog

The current version of Laravel (8 as of today) uses MailHog as the default application for testing email sending and general SMTP work during local development. Using the provided Docker Hub image, getting an instance set up and ready is simple and straight-forward. The service is included in the docker-compose.yml file, and spins up alongside the webserver and database services.

To see the dashboard and view any emails coming through the system, visit localhost:8025 after running docker-compose up -d site.

About

A docker-compose workflow for local Laravel development with PHP, Nginx, MySQL, PhpMyAdmin, Mailhog, Redis, NPM, Composer.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published