git clone https://github.com/yahyazini/simple-laravel-docker.git
cd simple-laravel-docker
git clone https://github.com/laravel/laravel.git web/src #or place your laravel app inside web/src
docker-compose up
#On a nother command propmt from the simple-laravel-docker location run:
docker exec -it web bash
composer install
php artisan key:generate
chgrp -R www-data storage bootstrap/cache
chmod -R ug+rwx storage bootstrap/cache
# This would allow you to see your docker host needed for DB_HOST
If you are using a mac, ensure you are sharing the project folder in the docker sharing tab under preferences
- Go to phpMyAdmin on http://localhost:8080 and log in using:
- username: root
- password: pass
- Create a new database to use it on DB_DATABASE.
- Copy and paste the .env.example content into .env and set the following:
DB_CONNECTION=mysql
DB_HOST= # Set this to the output of `docker network inspect bridge | grep Gateway`
DB_PORT=3306
DB_DATABASE=# Set this to your Database name
DB_USERNAME=root
DB_PASSWORD=pass
You can use the following command to access the web container's command line which would allow you to use npm, composer...
docker exec -it web bash
docker exec -it web bash
composer install
Use the web/Dockerfile's RUN section to add and install any necessary PHP libraries don't forget to rebuild and rerun after any changes to the settings:
docker-compose up --build
Use the web/php.ini's file to add or change any ini settings:
docker-compose up --build
Changing the FROM version in web/Dockerfile or mysql/Dockerfile and then rebuilding and running the container again would result in a change of the versions in the environment.
To track changes on the web/src
file you have to remove the src line from the .gitignore and refresh it.