I know there is Laradock which I demonstrated in my previous tutorial but I think it's too heavy to use besides we just need few files to make the project work.
You can clone the github repo at: https://github.com/jsafe00/laravel-docker-template.
Make sure you already have a docker toolbox installed and turned on in your local machine. If not, download docker toolbox here: https://docs.docker.com/toolbox/.
Note: I prefer to use docker toolbox because I'm having some problems installing docker desktop.
After cloning, execute docker-compose build. This will take time.
docker-compose up -d
Once the building is successful, execute the command above. This will create the containers. I have 3 services in my docker-compose.yml file: nginx, mysql and php_frm.
Execute docker ps to view the containers and its details.
Access your laravel project using the IP address in your docker with the port you specified in nginx service in docker-compose.yml file. You can also see the port when you execute docker ps - nginx container.
**Migrate and Seed **
docker exec -it ca61fd2b5aa6 bash
Execute command above. We used ca61fd2b5aa6 because this is the container id of our php.
php artisan migrate
php artisan db:seed
Once, you're inside the php container, execute migrate/seed artisan commands.
my .env data- db section db, username,password and port have the same setup in my docker-compose.yml file
I think how I dockerized my laravel project can still be improved and hope I can find a better way to even make this simpler. The simpler, the better.