DEV Community

Cover image for Build laravel development environment with docker
ucan_lab
ucan_lab

Posted on • Edited on

Build laravel development environment with docker

I created a nice development environment for Laravel 👍

Repository

https://github.com/ucan-lab/docker-laravel

Please try it ⭐️

Installing Docker

https://docs.docker.com/docker-for-mac/install/

Project Structure

.
├── src # Laravel project root directory
└── infra
     ├── docker
     │   ├── mysql
     │   │   ├── Dockerfile
     │   │   └── my.cnf
     │   ├── nginx
     │   │   ├── Dockerfile
     │   │   ├── Dockerfile.production
     │   │   └── default.conf
     │   └── php
     │       ├── Dockerfile
     │       ├── Dockerfile.production
     │       ├── bash
     │       │   ├── .bash_history
     │       │   └── psysh
     │       ├── php-fpm.d
     │       │   └── zzz-www.conf => unix domain socket config file
     │       ├── php.ini
     │       └── php.production.ini
     └── docker-compose.yml
Enter fullscreen mode Exit fullscreen mode

How to use

Read the Makefile for the contents

A. Create a new laravel project

$ git clone git@github.com:ucan-lab/docker-laravel.git
$ cd docker-laravel
$ mkdir -p src
$ docker compose build
$ docker compose up -d
$ docker compose exec app composer create-project --prefer-dist laravel/laravel .
$ docker compose exec app php artisan key:generate
$ docker compose exec app php artisan storage:link
$ docker compose exec app chmod -R 777 storage bootstrap/cache
$ docker compose exec app php artisan migrate
Enter fullscreen mode Exit fullscreen mode

http://localhost

B. Create a clone laravel project

$ git clone git@github.com:ucan-lab/docker-laravel.git
$ cd docker-laravel
$ mkdir -p src
$ docker compose build
$ docker compose up -d

$ docker compose exec app composer create-project --prefer-dist "laravel/laravel=6.*" .

$ docker compose exec app php artisan key:generate
$ docker compose exec app php artisan storage:link
$ docker compose exec app chmod -R 777 storage bootstrap/cache
$ docker compose exec app php artisan migrate
Enter fullscreen mode Exit fullscreen mode

http://localhost

Top comments (3)

Collapse
 
amitavroy7 profile image
Amitav Roy

Well, if you are sharing a repo publicly for others to use, then shouldn't you put things to default. I can see the timezone being set to Tokyo, Japan. Now, those who are not very familiar will be having a problem.

Collapse
 
ucan_lab profile image
ucan_lab • Edited

Thank you for your feedback. That's right.
The time zone, locale, and MySQL string collation were set to Japan.
It has been restored to the default so that many people can use it.

github.com/ucan-lab/docker-laravel...

Collapse
 
amitavroy7 profile image
Amitav Roy

Thank you for talking my feedback in a positive way and for that quick fix.