ronnyworm / simple-laravel-docker

A simple way to start a Laravel project using docker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use ?

git clone https://github.com/yahyazini/simple-laravel-docker.git

cd simple-laravel-docker # or check out start.sh and nextcommands.sh
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

Environment Configuration:

  • 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

Accessing the Web container from the command line

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

Composer Install as an example:

docker exec -it web bash
composer install

How do I add PHP libraries?

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

How do I Change PHP.ini settings?

Use the web/php.ini's file to add or change any ini settings:

docker-compose up --build

How do I change the version of PHP or MySQL

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.

Important Note:

To track changes on the web/src file you have to remove the src line from the .gitignore and refresh it.

About

A simple way to start a Laravel project using docker


Languages

Language:Shell 54.9%Language:Dockerfile 45.1%