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.