An open API service indexing awesome lists of open source software.

https://github.com/papposilene/dockerized-laravel

A docker-compose workflow for local Laravel development with PHP, Nginx, MySQL, PhpMyAdmin, Mailhog, Redis, NPM, Composer.
https://github.com/papposilene/dockerized-laravel

composer-docker docker-compose mailhog-docker mysql-docker nginx-docker npm-docker php-docker phpmyadmin-docker redis-docker

Last synced: 3 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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](https://dev.to/aschmelyun/the-beauty-of-docker-for-local-laravel-development-13c0).

## Usage

To get started, make sure you have [Docker installed](https://docs.docker.com/docker-for-mac/install/) 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](http://localhost:8025) after running `docker-compose up -d site`.